/* Nusa Island Stage 18: bag tabs, crafting cards, fishing reel HUD. Loaded after ui.css / hotbar.css. */

/* ---------- Bag header: tabs + Map ---------- */
#ui .inv-tabs { display: flex; align-items: flex-end; gap: 6px; }
#ui .inv-tab {
  position: relative;
  min-height: 40px;
  padding: 0 14px 4px;
  border: 0;
  border-radius: 3px 3px 0 0;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--f-display);
  font-weight: 900;
  font-size: 34px;
  line-height: 1;
  letter-spacing: .03em;
  text-transform: uppercase;
  opacity: .62;
  transition: opacity .12s, background-color .12s;
}
#ui .inv-tab:first-child { padding-left: 0; }
#ui .inv-tab::after {
  content: '';
  position: absolute;
  left: 14px; right: 14px; bottom: 0;
  height: 4px;
  background: var(--signal);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .22s var(--ease);
}
#ui .inv-tab:first-child::after { left: 0; }
#ui .inv-tab[aria-selected="true"] { color: var(--ink); opacity: 1; }
#ui .inv-tab[aria-selected="true"]::after { transform: scaleX(1); }
#ui .inv-tab:hover { opacity: 1; }
#ui .inv-head-r { display: flex; align-items: center; gap: 8px; }
#ui .btn-map svg { width: 18px; height: 18px; }

/* ---------- Tab switching: one scroller, two views ---------- */
#ui .inv[data-tab="craft"] .inv-grid,
#ui .inv[data-tab="craft"] .inv-empty,
#ui .inv[data-tab="craft"] .inv-actions { display: none !important; }
#ui .inv[data-tab="kit"] .craft { display: none; }

/* ---------- Craft cards ---------- */
#ui .craft { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 10px; }
#ui .craft-empty { grid-column: 1 / -1; padding: 36px 12px; text-align: center; font-size: 18px; color: var(--ink-soft); }
#ui .craft-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 12px 12px;
  border-radius: 3px;
  background: var(--canvas-shade);
  box-shadow: inset 0 0 0 1px var(--hairline);
  transition: background-color .12s, transform .16s var(--ease);
}
#ui .craft-card::after { /* pocket stitching */
  content: '';
  position: absolute;
  inset: 3px;
  border: 1.5px dashed var(--stitch);
  border-radius: 1px;
  pointer-events: none;
}
#ui .craft-card:hover, #ui .craft-card:focus-visible { background: #CFC4A9; }
#ui .craft-card.is-selected::after { border-color: var(--signal); }
#ui .craft-card:focus-visible { outline-offset: 1px; }
#ui .craft-top { display: flex; align-items: center; gap: 10px; }
#ui .craft-out { flex: none; width: 48px; height: 48px; display: grid; place-items: center; color: var(--ink-soft); }
#ui .craft-out img { width: 48px; height: 48px; object-fit: contain; pointer-events: none; }
#ui .craft-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
#ui .craft-name {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 24px;
  line-height: 1;
  letter-spacing: .03em;
  text-transform: uppercase;
}
#ui .craft-qty {
  padding: 2px 6px 1px;
  background: var(--ink);
  color: var(--signal);
  border-radius: 2px;
  font-family: var(--f-display);
  font-weight: 900;
  font-size: 17px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
#ui .craft-desc { display: none; font-size: 14px; line-height: 1.35; color: var(--ink-soft); }
#ui .craft-parts, #ui .craft-tools { display: flex; flex-wrap: wrap; gap: 6px; }
#ui .craft-chip, #ui .craft-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 2px 8px 2px 6px;
  border-radius: 3px;
  background: var(--canvas);
  box-shadow: inset 0 0 0 1px rgba(23, 20, 15, .3);
  font-family: var(--f-label);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .05em;
  text-transform: uppercase;
  line-height: 1;
}
#ui .chip-ic { width: 20px; height: 20px; display: grid; place-items: center; }
#ui .chip-ic:empty { display: none; }
#ui .chip-ic img { width: 20px; height: 20px; object-fit: contain; pointer-events: none; }
#ui .chip-name i { font-style: normal; font-weight: 600; color: var(--ink-soft); }
#ui .chip-count { font-family: var(--f-display); font-weight: 900; font-size: 17px; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
#ui .chip-count b { font-weight: 900; }
#ui .chip-count em { font-style: normal; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 2px; }
/* a short part: hatched, dashed, ink-soft (orange is reserved for live state) */
#ui .craft-chip.is-short, #ui .craft-tool.is-short {
  color: var(--ink-soft);
  background: repeating-linear-gradient(135deg, rgba(23, 20, 15, .12) 0 3px, transparent 3px 7px), var(--canvas);
  box-shadow: none;
  outline: 1.5px dashed var(--stitch);
  outline-offset: -2px;
}
#ui .craft-chip.is-short .chip-count b { opacity: .65; }
#ui .craft-chip.is-short .chip-count em { color: var(--ink); }
#ui .craft-tool { min-height: 24px; font-size: 13px; }
#ui .tool-k { padding: 2px 4px 1px; border-radius: 2px; background: var(--ink); color: var(--canvas); font-size: 11px; }
#ui .craft-msg {
  font-family: var(--f-label);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink);
}
#ui .craft-btn { min-height: 44px; margin-top: auto; touch-action: pan-y; }
#ui .craft-btn.is-off { color: var(--ink-soft); box-shadow: inset 0 0 0 1px rgba(23, 20, 15, .3); background: repeating-linear-gradient(135deg, rgba(23, 20, 15, .07) 0 3px, transparent 3px 7px); }
#ui .craft-card.is-crafted { animation: craft-settle .5s var(--ease); }
#ui .craft-card.is-crafted .craft-msg { color: var(--ink); }
#ui .craft-card.is-denied { animation: craft-shake .36s linear; }
@keyframes craft-settle { 0% { transform: scale(1.04); } 55% { transform: scale(.985); } 100% { transform: scale(1); } }
@keyframes craft-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }

html.is-touch #ui .inv-tab { min-height: 44px; }

@media (max-width: 640px) {
  #ui .inv-tab { font-size: 26px; padding-left: 10px; padding-right: 10px; }
  #ui .inv-tab::after { left: 10px; right: 10px; }
  #ui .craft { grid-template-columns: 1fr; }
  #ui .btn-map span, #ui .btn-x span { display: none; }
}

/* Small touch landscape (844x390, 667x375): cards fill the panel, detail aside gives way, text lives on the card */
@media (max-height: 500px), (max-width: 900px) {
  html.is-touch #ui .inv-tab { font-size: 24px; padding: 0 10px 2px; }
  html.is-touch #ui .inv-tab:first-child { padding-left: 0; }
  html.is-touch #ui .inv-tab::after { left: 10px; right: 10px; }
  html.is-touch #ui .inv-tab:first-child::after { left: 0; }
  html.is-touch #ui .inv-head { margin-bottom: 8px; }
  html.is-touch #ui .inv-head-r { gap: 6px; }
  html.is-touch #ui .btn-close span { display: inline; }
  html.is-touch #ui .inv[data-tab="craft"] .inv-detail { display: none; }
  html.is-touch #ui .craft { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  html.is-touch #ui .craft-card { gap: 6px; padding: 8px 8px 8px; }
  html.is-touch #ui .craft-out, html.is-touch #ui .craft-out img { width: 36px; height: 36px; }
  html.is-touch #ui .craft-name { font-size: 20px; }
  html.is-touch #ui .craft-desc { display: block; font-size: 13px; }
  html.is-touch #ui .craft-chip { min-height: 26px; font-size: 13px; }
  html.is-touch #ui .craft-btn { min-height: 44px; }
}

/* ---------- Fishing reel HUD ---------- */
#ui .hud { --reel-w: min(360px, calc(100vw - 32px)); }
#ui .reel {
  position: absolute;
  left: 50%;
  bottom: calc(var(--hb-top, 72px) + 58px); /* clears the needs bars at the hotbar left */
  width: var(--reel-w);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--hud);
  text-shadow: var(--hud-shadow);
  pointer-events: none;
}
#ui .reel-label, #ui .reel-sub {
  font-family: var(--f-label);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .08em;
  text-transform: uppercase;
  line-height: 1.1;
  text-align: center;
}
#ui .reel-sub { font-weight: 600; font-size: 14px; opacity: .85; }
#ui .reel[data-phase="wait"] .reel-label { font-size: 15px; opacity: .85; }
#ui .reel[data-phase="bite"] .reel-label { color: var(--signal); font-size: 26px; font-family: var(--f-display); font-weight: 900; }
#ui .reel.is-pulse .reel-label { animation: reel-pulse .5s var(--ease); }
@keyframes reel-pulse { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
#ui .reel-power {
  position: relative;
  width: 100%;
  height: 14px;
  border-radius: 2px;
  background: var(--canvas-shade);
  box-shadow: inset 0 0 0 1px var(--hairline), 0 2px 6px rgba(0, 0, 0, .35);
  overflow: hidden;
}
#ui .reel-power::after { content: ''; position: absolute; left: 4px; right: 4px; top: 50%; border-top: 1.5px dashed var(--stitch); transform: translateY(-50%); }
#ui .reel-power-fill { position: absolute; inset: 0; z-index: 1; transform-origin: left center; transform: scaleX(0); background: var(--signal); box-shadow: inset 0 -3px 0 rgba(27, 14, 6, .18); }
#ui .reel-meter { width: 100%; display: flex; flex-direction: column; gap: 6px; }
#ui .reel-bar {
  position: relative;
  height: 20px;
  border-radius: 2px;
  background: var(--canvas);
  box-shadow: inset 0 0 0 1px var(--hairline), 0 2px 6px rgba(0, 0, 0, .35);
}
#ui .reel-zone {
  position: absolute;
  top: 0; bottom: 0;
  background: repeating-linear-gradient(135deg, rgba(23, 20, 15, .16) 0 3px, transparent 3px 7px), var(--canvas-shade);
  border-left: 1.5px dashed var(--stitch);
  border-right: 1.5px dashed var(--stitch);
}
#ui .reel-needle {
  position: absolute;
  left: -2px; top: -5px;
  width: 4px; height: 30px;
  border-radius: 1px;
  background: var(--ink);
  box-shadow: 0 0 0 1px var(--canvas);
  will-change: transform;
  transition: background-color .08s;
}
#ui .reel-bar.is-out .reel-needle { background: var(--signal); }
#ui .reel-prog { height: 6px; border-radius: 2px; background: rgba(23, 20, 15, .6); box-shadow: inset 0 0 0 1px rgba(244, 239, 227, .3); overflow: hidden; }
#ui .reel-prog-fill { height: 100%; transform-origin: left center; transform: scaleX(0); background: var(--signal); }
#ui .hud.is-inv .reel, #ui .hud.is-examining .reel { visibility: hidden; }

/* touch: sit above the hotbar, clear of the Fire / Aim buttons on the right and the move stick on the left */
html.is-touch #ui .hud { --reel-w: min(340px, calc(100vw - 340px)); }
html.is-touch #ui .reel { bottom: calc(var(--hb-top) + 52px); gap: 4px; }
html.is-touch #ui .reel-label { font-size: 16px; }
html.is-touch #ui .reel[data-phase="bite"] .reel-label { font-size: 22px; }
html.is-touch #ui .reel-sub { font-size: 12px; }
html.is-touch #ui .reel-bar { height: 18px; }

@media (prefers-reduced-motion: reduce) {
  #ui .craft-card.is-denied, #ui .craft-card.is-crafted, #ui .reel.is-pulse .reel-label { animation: none !important; }
}

/* ---------- Stage 18b: close controls on every overlay ---------- */
#ui .ov-shade { position: absolute; inset: 0; z-index: 29; background: rgba(23, 20, 15, .18); touch-action: none; pointer-events: auto; }
#ui .ov-shade[hidden] { display: none; }
#ui .ov-x {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; min-height: 44px; padding: 0 10px;
  background: var(--canvas); color: var(--ink); border: 1.5px solid var(--stitch); border-radius: 3px;
  font: 700 14px/1 var(--f-label, 'Barlow Condensed', sans-serif); letter-spacing: .06em; text-transform: uppercase;
  cursor: pointer; pointer-events: auto; touch-action: manipulation;
}
#ui .ov-x:active { background: #CFC4A9; }
#ui .ov-x:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

#ui .ex-x { position: absolute; top: 8px; right: 8px; padding: 0; }
#ui .reel { pointer-events: none; }
#ui .reel-x { position: absolute; right: -6px; top: -48px; }
#ui .reel[data-phase="charge"] .reel-x, #ui .reel[data-phase="done"] .reel-x { display: none; }
html:not(.is-touch) #ui .reel-x span { display: none; }
#ui .examine-title, #ui .examine-text { padding-right: 48px; }
