/* ===========================
   EDH Tools • Unified Styles
   Mobile-first, dark theme
   (readability tuned for phones)
   =========================== */

/* --- Reset / base --- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
:root {
  /* Color tokens */
  --bg: #0f2a28;
  --bg-elev-1: #0f2523;
  --bg-elev-2: #112f2c;
  --fg: #e9f4f2;
  --fg-muted: #cfe4e1;
  --fg-dim: #a6c7c3;

  --accent: #1f9d86;
  --accent-ink: #032a22;

  --border: rgba(255,255,255,.12);
  --border-soft: rgba(255,255,255,.08);
  --shadow-inset: 0 1px 0 rgba(0,0,0,.18) inset;

  /* Sizing */
  --radius: 14px;
  --radius-lg: 16px;
  --pad: 14px;
  --tap: 52px;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.55 system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

a { color: #aee; text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 24px; margin: 14px 0 10px; font-weight: 800; }
h2 { font-size: 20px; margin: 12px 0 8px; font-weight: 700; }
p { margin: 10px 0; }

label { display:block; margin: 12px 0 8px; font-weight: 600; }

/* Inputs: do NOT force width on checkboxes/radios  */
input:not([type="checkbox"]):not([type="radio"]),
textarea, select {
  width: 100%;
  background: var(--bg-elev-1);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 17px; /* prevents iOS zoom */
}
textarea { min-height: 150px; }

/* Proper checkbox/radio sizing + alignment */
input[type="checkbox"], input[type="radio"] {
  width: auto;
  height: 20px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  vertical-align: middle;
}

/* --- Layout helpers --- */
.container { max-width: 880px; margin: 16px auto; padding: 0 var(--pad); }
.stack-8  > * + * { margin-top: 8px; }
.stack-12 > * + * { margin-top: 12px; }
.stack-16 > * + * { margin-top: 16px; }
.row { display:flex; align-items:center; gap: 10px; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
@media (min-width: 660px) { .grid.grid-2 { grid-template-columns: 1fr 1fr; } }

/* --- Cards / tiles --- */
.card {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-inset);
}
.card--clickable { cursor: pointer; }
.card--clickable:active { transform: translateY(1px); }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap);
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #0b0b0b; color: #fff;
  font-weight: 800; letter-spacing: .2px;
  transition: filter .12s ease;
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .6; pointer-events: none; }
.btn--ghost { background: transparent; color: var(--fg); border-color: var(--border-soft); }
.btn--small { min-height: 36px; padding: 7px 12px; border-radius: 10px; font-weight: 700; }
.btn--danger { background: #b33939; border-color: rgba(255,255,255,.18); }

/* Key/value micro-styles used across pages */
.k { color: var(--fg-dim); font-size: 14px; }
.v { font-weight: 800; font-size: 16px; }

/* --- Chips --- */
.chips { display:flex; gap:8px; overflow:auto; -webkit-overflow-scrolling:touch; }
.chip {
  padding: 8px 12px; border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: var(--fg); white-space: nowrap; font-size: 15px;
}
.chip--active { background: var(--accent); color: var(--accent-ink); font-weight: 800; }

/* --- Sticky bars --- */
.sticky-top {
  position: sticky; top: 0; z-index: 8;
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
}
.sticky-bottom {
  position: sticky; bottom: 0; z-index: 9;
  background: linear-gradient(180deg, rgba(15,42,40,.6), rgba(15,42,40,.95));
  backdrop-filter: blur(6px);
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-soft);
}
.actionbar { display:grid; gap:12px; grid-template-columns: 1fr auto; }
@media (max-width: 420px) { .actionbar { grid-template-columns: 1fr 1fr; } }

/* --- Toasts --- */
.toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #1b3a38; color: #fff; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.35); }

/* --- Log --- */
.log { margin-top: 14px; }
.log__box { border:1px solid var(--border); background: var(--bg-elev-1); border-radius: var(--radius); padding:12px; min-height:54px; max-height:260px; overflow:auto; }
.log__toggle { background:none; border:none; color:#aee; text-decoration:underline; padding:6px 8px; }

/* --- Treasure choice cards --- */
.choice { border:1px solid var(--border); background: var(--bg-elev-2); border-radius: var(--radius); padding:14px; box-shadow: var(--shadow-inset); }
.choice__name { font-weight:800; margin-bottom:8px; font-size:17px; }
.choice__btn { display:inline-block; padding:10px 12px; border-radius:10px; background:#0c0c0c; color:#fff; font-weight:700; }

/* --- Utilities --- */
.muted { color: var(--fg-dim); }
.center { text-align: center; }
.hide { display: none !important; }

/* === Images for Treasure Cruise === */
.reveal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 560px) { .reveal-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card-img {
  width: 100%; aspect-ratio: 488 / 680; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--border); background: var(--bg-elev-1); display: block;
}
.thumb-row { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.thumb {
  flex: 0 0 auto; width: 96px; aspect-ratio: 488 / 680; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--border); background: var(--bg-elev-1); box-shadow: var(--shadow-inset);
}

/* ============================
   Treasure Cruise (treasure feature) — merged styles
   ============================ */

/* Cards grid */
.tc-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
@media (min-width: 480px) {
  .tc-cards { grid-template-columns: repeat(4, 1fr); }
}

/* Card tile */
.tc-card {
  display: block;
  position: relative;           /* needed for the "Choose" badge */
  border-radius: 10px;
  overflow: hidden;
  background: #0a0a0a;
  border: 1px solid #1b1b1b;
}
.tc-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* High-visibility banner shown when a 6 is rolled */
.tc-banner {
  margin: 8px 0 12px;
  padding: 8px 12px;
  background: linear-gradient(180deg, #163a2a, #0f2d23);
  border: 1px solid #2f7a49;
  border-radius: 10px;
  color: #dffbe9;
  font-weight: 700;              /* slightly bolder than before */
  letter-spacing: .2px;
}

/* Highlight the Top-of-Deck container while choosing */
#tc-deck.tc-choice {
  border: 2px dashed #91f29f;
  background: rgba(30, 70, 40, .25);
  box-shadow: 0 0 0 2px #2f7a49 inset;
  position: relative;
}
#tc-deck.tc-choice::after {
  content: "Click a card to keep it";
  position: absolute;
  top: -12px;
  right: 10px;
  font-size: 12px;
  background: #163a2a;
  color: #dffbe9;
  border: 1px solid #2f7a49;
  border-radius: 999px;
  padding: 2px 10px;
}

/* Clickability cues for the 3 revealed cards */
.tc-card.clickable img {
  outline: 3px solid #91f29f;   /* stronger, more visible */
  cursor: pointer;
  animation: tcPulse 1200ms ease-in-out infinite;
}
.tc-card.clickable:hover img,
.tc-card.clickable:focus-within img,
.tc-card.clickable:focus-visible img {
  outline-color: #c9ffcf;
  transform: translateY(-1px);
  transition: transform 120ms ease;
}

/* Small helper label on hover/focus */
.tc-card.clickable::before {
  content: "Choose";
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: rgba(0,0,0,.6);
  color: #fff;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .15s ease, transform .15s ease;
  pointer-events: none;
}
.tc-card.clickable:hover::before,
.tc-card.clickable:focus-within::before,
.tc-card.clickable:focus-visible::before {
  opacity: 1;
  transform: translateY(0);
}

/* Kept card highlight (shown in Top of Deck after a 1–5 roll) */
.tc-card.kept img {
  outline: 3px solid #ffd166;                /* gold-ish */
  box-shadow: 0 0 0 3px rgba(255, 209, 102, .25);
}
.tc-card.kept::after {
  content: "Kept";
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0,0,0,.7);
  color: #fff;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
}

/* Gentle pulse to draw attention in choice mode */
@keyframes tcPulse {
  0%   { box-shadow: 0 0 0 0 rgba(145, 242, 159, .55); }
  70%  { box-shadow: 0 0 0 12px rgba(145, 242, 159, 0); }
  100% { box-shadow: 0 0 0 0 rgba(145, 242, 159, 0); }
}

.btn--danger {
  background: #7a1f1f;
  border-color: #b33;
  color: #fff;
}
.btn--danger:hover {
  background: #962929;
  border-color: #d55;
}
.btn--ghost.btn--danger {
  background: transparent;
  color: #ffb8b8;
  border-color: #b33;
}
.btn--ghost.btn--danger:hover {
  background: rgba(122, 31, 31, 0.12);
}

/* Player chips track */
#tc-players {
  position: relative;
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 32px;
}

/* Sliding highlight behind the active chip */
#tc-player-slider {
  position: absolute;
  left: 0; top: 0;
  width: 0; height: 0;
  border-radius: 999px;
  background: #163a2a;
  border: 1px solid #2f7a49;
  box-shadow: 0 2px 8px rgba(0,0,0,.25) inset;
  transition: left 180ms ease, top 180ms ease, width 180ms ease, height 180ms ease, opacity 120ms ease;
  opacity: 0;
  z-index: 0;
}

/* Chips themselves (names only); keep backgrounds transparent so the slider shows */
.pill {
  position: relative;
  z-index: 1;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #2c3d3a;
  background: transparent;
  color: #cfe4de;
  font-weight: 600;
  letter-spacing: .2px;
}

/* Emphasis on active chip */
.pill--on { color: #e8fff6; }

.tc-card.kept img {
  outline: 3px solid #ffd166;
  box-shadow: 0 0 0 3px rgba(255, 209, 102, .25);
}
.tc-card.kept::after {
  content: "Kept";
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0,0,0,.7);
  color: #fff;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
}

/* === Chosen-card flash overlay ========================================== */
#tc-flash {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;             /* don't block clicks */
  z-index: 9999;
  opacity: 0;
}
#tc-flash.show { animation: tcFlashFade 1200ms ease forwards; }

#tc-flash .card {
  border-radius: 12px;
  overflow: hidden;
  transform: scale(.86);
  filter: drop-shadow(0 18px 48px rgba(0,0,0,.55));
  animation: tcFlashPop 1200ms cubic-bezier(.2,.9,.2,1) forwards;
  position: relative;
}

#tc-flash .card img {
  display: block;
  width: min(42vmin, 420px);
  height: auto;
}

/* subtle “kept” burst ring */
@keyframes tcFlashPop {
  0%   { transform: scale(.86); box-shadow: 0 0 0 0 rgba(255,214,102,0); }
  15%  { transform: scale(1.04); }
  30%  { transform: scale(1.0); box-shadow: 0 0 0 10px rgba(255,214,102,.40); }
  60%  { box-shadow: 0 0 0 0 rgba(255,214,102,0); }
  100% { transform: scale(1.0); }
}

@keyframes tcFlashFade {
  0%   { opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { opacity: 0; }
}
