/* Teli Games — a two-ink printed card deck. Card backs carry a khatam (8-point star) lattice. */

:root {
  --stock: #FCFCFA;   /* card stock */
  --ink: #141B4D;     /* navy printing ink */
  --red: #D3243C;     /* deck red */
  --blue: #2F4FC4;    /* deck blue */
  --mist: #E9ECF4;    /* photo mat / quiet panels */

  --page: var(--stock);
  --text: var(--ink);
  --muted: #4A5285;
  --line: rgba(20, 27, 77, 0.16);
  --accent: var(--red);
  --link: var(--blue);
  --panel: var(--mist);

  --display: "Lalezar", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --body: "IBM Plex Sans Arabic", system-ui, sans-serif;

  /* Perfect-fourth scale on an 18px base. */
  --s-1: 0.844rem;
  --s0: 1.125rem;
  --s1: 1.5rem;
  --s2: 2rem;
  --s3: 2.666rem;
  --s4: 3.555rem;

  --card-radius: 5.5%/3.9%; /* real playing-card corner, 63×88mm */
  --gutter: clamp(16px, 4vw, 48px);
  --measure: 36rem;

  /* Khatam tile: two squares make the 8-point star, joined at the tile corners. */
  --khatam-blue: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg fill='none' stroke='%232F4FC4' stroke-width='1.4'%3E%3Cpath d='M8 8h16v16H8z'/%3E%3Cpath d='M16 4.7 27.3 16 16 27.3 4.7 16z'/%3E%3Cpath d='M0 0l4.7 4.7M32 0l-4.7 4.7M0 32l4.7-4.7M32 32l-4.7-4.7'/%3E%3C/g%3E%3Ccircle cx='16' cy='16' r='2.2' fill='%232F4FC4'/%3E%3C/svg%3E");
  --khatam-red: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg fill='none' stroke='%23D3243C' stroke-width='1.4'%3E%3Cpath d='M8 8h16v16H8z'/%3E%3Cpath d='M16 4.7 27.3 16 16 27.3 4.7 16z'/%3E%3Cpath d='M0 0l4.7 4.7M32 0l-4.7 4.7M0 32l4.7-4.7M32 32l-4.7-4.7'/%3E%3C/g%3E%3Ccircle cx='16' cy='16' r='2.2' fill='%23D3243C'/%3E%3C/svg%3E");
  --khatam-stock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg fill='none' stroke='%23FCFCFA' stroke-opacity='.5' stroke-width='1.4'%3E%3Cpath d='M8 8h16v16H8z'/%3E%3Cpath d='M16 4.7 27.3 16 16 27.3 4.7 16z'/%3E%3Cpath d='M0 0l4.7 4.7M32 0l-4.7 4.7M0 32l4.7-4.7M32 32l-4.7-4.7'/%3E%3C/g%3E%3C/svg%3E");

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0E1338;
    --text: #F1F2FA;
    --muted: #B4BAE0;
    --line: rgba(241, 242, 250, 0.16);
    --accent: #FF5A6E;
    --link: #9DB0FF;
    --panel: #1A2160;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--body);
  font-size: var(--s0);
  line-height: 1.75;
  text-rendering: optimizeLegibility;
}

:lang(en) body, body:lang(en) { line-height: 1.6; }

img { display: block; max-width: 100%; }

a { color: var(--link); text-underline-offset: 0.2em; }

:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 3px;
  border-radius: 4px;
}

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 400; /* Lalezar has a single, heavy weight */
  line-height: 1.15;
  margin: 0;
}

.skip {
  position: absolute;
  inset-inline-start: var(--gutter);
  top: -100px;
  background: var(--ink);
  color: var(--stock);
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip:focus { top: 8px; }

/* ---------- Masthead ---------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem var(--gutter);
  max-width: 1200px;
  margin: 0 auto;
}

.wordmark {
  font-family: var(--display);
  font-size: var(--s1);
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.01em;
  margin: 0;
  direction: ltr;
  unicode-bidi: isolate;
}

.masthead-actions { display: flex; align-items: center; gap: 0.75rem; }

.ig-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
  text-decoration: none;
  font-size: var(--s-1);
  font-weight: 500;
  direction: ltr;
}
.ig-link:hover span { text-decoration: underline; }

.lang-toggle {
  font: 500 var(--s-1)/1 var(--body);
  color: var(--text);
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  cursor: pointer;
}
.lang-toggle:hover { border-color: var(--text); }

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.7rem 1.5rem;
  border-radius: 999px;
  border: 2px solid var(--text);
  background: transparent;
  color: var(--text);
  font: 600 var(--s0)/1.2 var(--body);
  text-decoration: none;
  cursor: pointer;
}
.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.button-primary:hover { filter: brightness(1.08); }
.button:disabled { opacity: 0.6; cursor: progress; }

/* ---------- Playing cards ---------- */

.pcard {
  aspect-ratio: 63 / 88;
  border-radius: var(--card-radius);
  background: var(--stock);
  box-shadow: 0 1px 0 rgba(20, 27, 77, 0.25), 0 10px 24px -12px rgba(20, 27, 77, 0.55);
  position: relative;
}

.pcard-back::before {
  content: "";
  position: absolute;
  inset: 6%;
  border-radius: 4%/2.9%;
  background-size: 30px 30px;
  background-position: center;
}
.back-blue::before { background-image: var(--khatam-blue); border: 2px solid var(--blue); }
.back-red::before { background-image: var(--khatam-red); border: 2px solid var(--red); }

.pcard-face { color: var(--red); }
.pcard-face .index {
  position: absolute;
  font-family: var(--display);
  font-size: clamp(1rem, 2.4vw, 1.6rem);
  line-height: 1;
}
.pcard-face .index-top { top: 7%; inset-inline-start: 9%; }
.pcard-face .index-bottom { bottom: 7%; inset-inline-end: 9%; transform: rotate(180deg); }
.pcard-face .pip {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: clamp(3.5rem, 9vw, 6.5rem);
  line-height: 1;
}

/* ---------- Hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(2rem, 6vw, 5rem);
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 4rem) var(--gutter) clamp(3rem, 8vw, 6rem);
}

.hero h1 {
  font-size: clamp(3rem, 8.5vw, 6rem);
  color: var(--text);
  text-wrap: balance;
}
:lang(en) .hero h1 { line-height: 1.02; }

.hero-lead {
  font-size: clamp(var(--s0), 2vw, 1.3rem);
  color: var(--muted);
  max-width: 30rem;
  margin: 1.25rem 0 2rem;
}

/* The fan: five cards dealt from one stack, once, on load. */
.fan {
  --spread: 13deg;
  position: relative;
  height: clamp(260px, 38vw, 440px);
  display: grid;
  place-items: end center;
}
.fan .pcard {
  position: absolute;
  bottom: 0;
  width: clamp(130px, 19vw, 220px);
  transform-origin: 50% 120%;
  transform: rotate(0deg) translateY(12px);
  transition: transform 700ms cubic-bezier(0.2, 0.8, 0.2, 1);
  transition-delay: calc(var(--i) * 70ms);
}
.fan.dealt .pcard { transform: rotate(calc((var(--i) - 2) * var(--spread))); }
.fan.dealt:hover { --spread: 16deg; }
.fan.dealt:hover .pcard { transition-delay: 0ms; transition-duration: 300ms; }

/* ---------- Boxes ---------- */

.boxes {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--gutter) clamp(4rem, 9vw, 7rem);
}

.section-head {
  border-top: 3px solid var(--text);
  padding-top: 1.25rem;
  margin-bottom: clamp(2rem, 5vw, 3.5rem);
  display: grid;
  grid-template-columns: auto minmax(0, var(--measure));
  gap: 0.5rem 3rem;
  align-items: baseline;
}
.section-head h2 { font-size: var(--s3); }
.section-head p { margin: 0; color: var(--muted); }

.box-list { display: grid; gap: clamp(3.5rem, 8vw, 6rem); }

.box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: start;
}

/* Gallery */
.gallery-main {
  aspect-ratio: 4 / 5;
  background: var(--panel);
  border-radius: 14px;
  overflow: hidden;
  margin: 0;
}
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-empty {
  display: grid;
  place-items: center;
  background-color: var(--stock);
  background-image: var(--khatam-blue);
  background-size: 44px 44px;
  background-position: center;
  border: 2px solid var(--blue);
}
.gallery-empty span {
  background: var(--stock);
  color: var(--ink);
  font-family: var(--display);
  font-size: var(--s2);
  padding: 0.4rem 1.2rem;
  border-radius: 999px;
}

.thumbs {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.75rem;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.thumb {
  flex: 0 0 auto;
  width: 72px;
  aspect-ratio: 1;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
  cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb[aria-pressed="true"] { border-color: var(--text); }

/* Details: stays in view beside a tall gallery */
.box-info { position: sticky; top: 1.5rem; }
.box-info h3 { font-size: clamp(var(--s2), 4.2vw, var(--s3)); }
.price {
  font-family: var(--display);
  font-size: var(--s2);
  color: var(--accent);
  margin: 0.4rem 0 1.25rem;
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}
.box-desc { max-width: var(--measure); margin: 0 0 1.75rem; }

.in-box h4 {
  font: 600 var(--s0)/1.3 var(--body);
  margin: 0 0 0.75rem;
}
/* Each game in the box is drawn as a small card. */
.hand {
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.hand li {
  position: relative;
  min-width: 7.5rem;
  max-width: 12rem;
  padding: 0.85rem 0.9rem 0.85rem 0.9rem;
  padding-inline-start: 1.9rem;
  background: var(--stock);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  font-weight: 600;
  font-size: var(--s-1);
  line-height: 1.4;
}
.hand li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0.6rem;
  top: 0.95rem;
  width: 0.7rem;
  height: 0.7rem;
  background: var(--red);
  transform: rotate(45deg);
  border-radius: 1px;
}
.hand li:nth-child(even)::before { background: var(--blue); }

.loading, .empty { color: var(--muted); }
.empty {
  border: 2px dashed var(--line);
  border-radius: 14px;
  padding: 2rem;
  max-width: var(--measure);
}
.empty strong { display: block; font-family: var(--display); font-weight: 400; font-size: var(--s2); color: var(--text); }

/* ---------- Colophon ---------- */

.colophon { background: var(--ink); color: var(--stock); }
.colophon-band {
  height: 28px;
  background-color: var(--ink);
  background-image: var(--khatam-stock);
  background-size: 28px 28px;
  border-bottom: 2px solid var(--red);
}
.colophon-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem var(--gutter) 3rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem 2.5rem;
  align-items: center;
}
.colophon .wordmark { color: var(--stock); }
.colophon-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.75rem; }
.colophon a { color: var(--stock); }
.colophon-note { margin: 0; color: #C9CDEB; }

/* ---------- Preorder sheet ---------- */

.sheet {
  width: min(32rem, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--stock);
  color: var(--ink);
  box-shadow: 0 24px 60px -20px rgba(14, 19, 56, 0.6);
}
.sheet::backdrop { background: rgba(14, 19, 56, 0.55); }
.sheet[open] { animation: sheet-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes sheet-in { from { transform: translateY(16px); opacity: 0; } }

.sheet-body { padding: clamp(1.25rem, 4vw, 2rem); }
.sheet-head {
  position: relative;
  padding-inline-end: 3rem;
  margin-bottom: 1.25rem;
}
.sheet-head h2 { font-size: var(--s2); }
.sheet-price { margin: 0.25rem 0 0; color: var(--red); font-weight: 600; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.sheet-close {
  position: absolute;
  top: -0.25rem;
  inset-inline-end: -0.25rem;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--mist);
  color: var(--ink);
  cursor: pointer;
}

.field { margin-bottom: 1.1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.optional { font-weight: 400; color: #5A6190; }
.field input, .field select {
  width: 100%;
  min-height: 48px;
  font: 400 var(--s0)/1.4 var(--body);
  color: var(--ink);
  background: #fff;
  border: 1.5px solid rgba(20, 27, 77, 0.35);
  border-radius: 10px;
  padding: 0.6rem 0.85rem;
}
.field input:focus, .field select:focus { border-color: var(--blue); outline: 2px solid var(--blue); outline-offset: 1px; }
.field input[aria-invalid="true"] { border-color: var(--red); }
.field input[dir="ltr"] { text-align: left; }
.field-qty select { width: 6rem; }
.field-hint { margin: 0.35rem 0 0; font-size: var(--s-1); color: #5A6190; }
.field-error { margin: 0.35rem 0 0; font-size: var(--s-1); color: var(--red); font-weight: 600; }

.turnstile-slot { min-height: 65px; margin: 0.5rem 0 0.75rem; }
.form-status { min-height: 1.5em; margin: 0 0 0.75rem; font-weight: 600; color: var(--red); }
.sheet-actions .button { width: 100%; }

.sheet-done { text-align: center; }
.done-card { width: 96px; margin: 0.5rem auto 1.25rem; }
.done-card .pip { font-size: 2.6rem; }
.done-card .index { font-size: 0.9rem; }
.sheet-done h2 { font-size: var(--s2); margin-bottom: 0.5rem; outline: none; }
.sheet-done p { margin: 0 auto 1.5rem; max-width: 24rem; }
.sheet-done .button { color: var(--ink); border-color: var(--ink); }

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; }
  .fan { order: -1; height: 230px; }
  .fan .pcard { width: 120px; }
  .section-head { grid-template-columns: 1fr; }
  .box { grid-template-columns: 1fr; }
  .box-info { position: static; }
  .colophon-inner { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .ig-link span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .fan .pcard, .sheet[open] { transition: none; animation: none; }
}
