/* === Reset & Base === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --cream: #F8EDD9;
  --cream-muted: rgba(248, 237, 217, 0.55);
  --accent: #73C7AD;
  --accent-glow: rgba(115, 199, 173, 0.4);
  --border: rgba(255,255,255,0.07);
  --radius: 16px;
  --max-width: 1100px;

  /* Theme backgrounds (from AppTheme.swift) */
  --midnight-bg:  #2E3847;
  --midnight-card:#242B38;
  --forest-bg:    #293829;
  --forest-card:  #1F2E24;
  --violet-bg:    #332E42;
  --violet-card:  #292438;
  --dusk-bg:      #3D3024;
  --dusk-card:    #33261A;
  --slate-bg:     #33363B;
  --slate-card:   #292B30;
  --rose-bg:      #422938;
  --rose-card:    #381F2E;
  --hotpink-bg:   #47142E;
  --hotpink-card: #380A24;
  --mono-bg:      #2E2E2E;
  --mono-card:    #242424;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--cream);
  background: var(--midnight-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }

/* === Typography — matches app === */
.title-chess {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 400;
  color: var(--cream);
}

.title-peace {
  font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 600;
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow), 0 0 40px rgba(115,199,173,0.2);
  letter-spacing: -0.01em;
}

h2 {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 400;
  color: var(--cream);
  line-height: 1.2;
}

h3 { color: var(--cream); line-height: 1.2; }

.mode-text h3 {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 400;
  font-size: 1.8rem;
  color: var(--accent);
  text-shadow: 0 0 16px var(--accent-glow);
  margin-bottom: 14px;
}

.section-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* === Phone Frame === */
.phone-frame {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 280px;
  aspect-ratio: 1350 / 2760;
}

.phone-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('images/blank-frame.png');
  background-size: 100% 100%;
  pointer-events: none;
  z-index: 1;
}

.phone-frame img {
  position: absolute;
  top: 2.54%;
  left: 5.41%;
  width: 89.11%;
  height: 96.52%;
  object-fit: cover;
  object-position: top center;
  display: block;
  max-width: none;
  /* Clip corners to match the phone frame's rounded screen corners.
     Top corners: transparent ~51 PNG px (10.6 CSS px) from left edge.
     Bottom corners: much larger — up to 188 PNG px (39 CSS px) from left edge.
     Syntax: top-left top-right bottom-right bottom-left / h-radii / v-radii */
  -webkit-clip-path: inset(0 round 10% 10% 25% 25% / 4% 4% 5% 5%);
  clip-path: inset(0 round 10% 10% 25% 25% / 4% 4% 5% 5%);
}

.phone-frame-small { width: 220px; }

/* === App Store Button === */
.hero-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.support-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--accent);
  font-size: 0.9rem;
  text-decoration: none;
  padding: 10px 16px;
  border: 1px solid rgba(115,199,173,0.5);
  border-radius: 12px;
  transition: background 0.2s, border-color 0.2s;
  white-space: nowrap;
  align-self: stretch; /* match height of App Store button */
}

.support-btn:hover {
  background: rgba(115,199,173,0.1);
  border-color: var(--accent);
}

.app-store-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  color: #000;
  border-radius: 12px;
  padding: 10px 20px;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s;
  border: none;
}

.app-store-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  color: #000;
}

.app-store-btn__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.app-store-btn__text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.app-store-btn__small {
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.app-store-btn__big {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* === Hero — Midnight === */
.hero {
  background: var(--midnight-bg);
  min-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 80px;
  padding: 80px 40px;
  overflow: hidden;
}

.hero-content { max-width: 460px; }

.hero-icon {
  width: 120px;
  height: 120px;
  border-radius: 26px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  margin-bottom: 24px;
}

.hero h1 {
  font-size: 3.5rem;
  margin-bottom: 12px;
  line-height: 1.1;
}

.tagline {
  font-size: 1.2rem;
  color: var(--cream-muted);
  margin-bottom: 12px;
}

.subtitle {
  font-size: 1.05rem;
  color: var(--cream-muted);
  margin-bottom: 32px;
  max-width: 400px;
}

/* === Hero Animated Board ===
   Exact match to SplashPhaseView / OBChessBoardView in the app.
   Cell colors from OnboardingBoardView:
     light = Color(red:0.84, green:0.79, blue:0.70) = rgb(214,201,178)
     dark  = Color(red:0.45, green:0.38, blue:0.32) = rgb(115,97,82)
   Token:  cellSize*0.80 circle, rgba(28,28,30,0.75) bg (systemGray6 dark mode), 1.5px border
   Glow:   tokenSize*1.5 circle at 50% opacity, blur 12px, appears after all pieces land
*/
.chess-board {
  --cs: 86px;   /* cell size */
  --cg: 2px;    /* gap */
  --ct: calc(var(--cs) + var(--cg)); /* step */
  position: relative;
  /* 4 cols × 86 + 3 gaps × 2 = 350px */
  width: calc(4 * var(--cs) + 3 * var(--cg));
  height: calc(4 * var(--cs) + 3 * var(--cg));
  flex-shrink: 0;
}

.bc {
  position: absolute;
  width: var(--cs);
  height: var(--cs);
  left: calc(var(--c) * var(--ct));
  top: calc(var(--r) * var(--ct));
  border-radius: calc(var(--cs) * 0.12);
}
.bc.l { background: rgb(214,201,178); }
.bc.d { background: rgb(115,97,82); }

/* Piece wrapper — same footprint as a cell */
.bp {
  position: absolute;
  width: var(--cs);
  height: var(--cs);
  left: calc(var(--c) * var(--ct));
  top: calc(var(--r) * var(--ct));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  animation: ob-piece-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: var(--delay, 0s);
}

/* Glow behind token — matches solvedGlow: tokenSize*1.5 circle, blur 12 */
.bp::before {
  content: '';
  position: absolute;
  width: calc(var(--cs) * 1.2);   /* tokenSize*1.5 = cellSize*0.8*1.5 = cellSize*1.2 */
  height: calc(var(--cs) * 1.2);
  border-radius: 50%;
  background: var(--gc, transparent);
  filter: blur(12px);
  opacity: 0;
  animation: ob-glow-in 0.7s ease both;
  animation-delay: var(--glow-delay, 3.0s);
  z-index: -1;
}

/* Token circle — Color(.systemGray6).opacity(0.75) in dark mode ≈ rgba(28,28,30,0.75) */
.bp-token {
  width: calc(var(--cs) * 0.80);
  height: calc(var(--cs) * 0.80);
  border-radius: 50%;
  background: rgba(28,28,30,0.75);
  border: 1.5px solid var(--bc2, rgba(255,255,255,0.5));
  box-shadow: 0 2px 3px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Piece image — tokenSize * 0.576 wide, * 0.512 tall */
.bp-token img {
  width: calc(var(--cs) * 0.80 * 0.576);
  height: calc(var(--cs) * 0.80 * 0.512);
  object-fit: contain;
  max-width: none;
  position: static;
  border-radius: 0;
}

@keyframes ob-piece-in {
  0%   { opacity: 0; transform: scale(0.5); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes ob-glow-in {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

/* === Sections === */
.section { padding: 100px 40px; }

.section h2 {
  font-size: 2.2rem;
  text-align: center;
  margin-bottom: 8px;
}

.section-subtitle {
  text-align: center;
  color: var(--cream-muted);
  font-size: 1.05rem;
  margin-bottom: 56px;
}

/* === How It Works — Forest === */
.how-it-works { background: var(--forest-bg); }

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 48px;
}

.step { text-align: center; }
.step .phone-frame { margin: 0 auto 20px; }
.step h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; }
.step p { color: var(--cream-muted); font-size: 0.95rem; }

/* === Modes — Violet === */
.modes { background: var(--violet-bg); }

.mode-row {
  display: flex;
  align-items: center;
  gap: 64px;
  margin-bottom: 80px;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
}

.mode-row:last-child { margin-bottom: 0; }
.mode-row-reverse { flex-direction: row-reverse; }
.mode-text { flex: 1; }
.mode-text p { color: var(--cream-muted); font-size: 1.05rem; line-height: 1.7; }

/* Extra modes grid */
.modes-extra-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px;
  margin-top: 80px;
}

.mode-card {
  text-align: center;
}

.mode-card .phone-frame {
  margin: 0 auto 16px;
}

.mode-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--accent);
}

.mode-card p {
  color: var(--cream-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* === Customisation — Hot Pink === */
.customisation { background: var(--hotpink-bg); }

.customisation-text h2 { text-align: left; margin-bottom: 16px; }

.customisation-text p {
  color: var(--cream-muted);
  font-size: 1.05rem;
  line-height: 1.7;
  margin-bottom: 20px;
  max-width: 440px;
}

.customisation-content {
  display: flex;
  align-items: center;
  gap: 64px;
  justify-content: center;
}

.customisation-text h2 { text-align: left; margin-bottom: 16px; }

.customisation-text p {
  color: var(--cream-muted);
  font-size: 1.05rem;
  line-height: 1.7;
  margin-bottom: 20px;
  max-width: 440px;
}

.customisation-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.customisation-list li {
  color: var(--cream-muted);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.customisation-list li::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* === Screenshots — Slate === */
.screenshots { background: var(--slate-bg); }

.screenshot-scroll {
  display: flex;
  gap: 24px;
  overflow-x: auto;
  padding: 0 40px 20px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.screenshot-scroll .phone-frame { scroll-snap-align: center; flex-shrink: 0; width: 220px; }
.screenshot-scroll::-webkit-scrollbar { display: none; }
.screenshot-scroll { -ms-overflow-style: none; scrollbar-width: none; }

/* === Quotes — Rose === */
.quotes { background: var(--rose-bg); }

.quotes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.quote-card {
  background: var(--rose-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  position: relative;
}

.quote-card::before {
  content: "\201C";
  font-size: 3rem;
  color: var(--accent);
  opacity: 0.3;
  position: absolute;
  top: 12px;
  left: 20px;
  line-height: 1;
}

.quote-card blockquote {
  font-size: 1.0rem;
  font-style: italic;
  color: var(--cream);
  line-height: 1.6;
  margin-bottom: 12px;
}

.quote-card cite {
  font-style: normal;
  font-size: 0.85rem;
  color: var(--cream-muted);
}

/* === Features — Dusk === */
.features { background: var(--dusk-bg); }

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.feature {
  background: var(--dusk-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 22px;
  transition: transform 0.2s, border-color 0.2s;
}

.feature:hover {
  transform: translateY(-3px);
  border-color: rgba(115,199,173,0.25);
}

.feature h3 { font-size: 1.0rem; font-weight: 600; margin-bottom: 6px; }
.feature p { color: var(--cream-muted); font-size: 0.9rem; }

/* === FAQ — Forest === */
.faq { background: var(--forest-bg); }

.faq-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.faq-item {
  background: var(--forest-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 22px;
}

.faq-item h3 {
  font-size: 1.0rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}

.faq-item p {
  color: var(--cream-muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.faq-item a { color: var(--accent); }

@media (max-width: 600px) {
  .faq-grid { grid-template-columns: 1fr; }
}

/* === CTA — Mono === */
.cta {
  text-align: center;
  background: var(--mono-bg);
}

.cta-icon {
  width: 80px;
  height: 80px;
  border-radius: 18px;
  margin: 0 auto 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.cta h2 { font-size: 2rem; margin-bottom: 12px; }
.cta p { color: var(--cream-muted); font-size: 1.05rem; margin-bottom: 28px; }
.cta-support { margin-top: 20px; margin-bottom: 0; font-size: 0.95rem; }
.cta-support a { color: var(--accent); }

/* === Footer — Mono (darker) === */
footer {
  background: var(--mono-card);
  border-top: 1px solid var(--border);
  color: var(--cream-muted);
  padding: 48px 40px;
}

.footer-content {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--cream-muted);
  font-size: 0.9rem;
  transition: color 0.2s;
}

.footer-links a:hover { color: var(--cream); }
.footer-contact { font-size: 0.9rem; margin-bottom: 16px; }
.footer-contact a { color: var(--accent); }
.footer-copy { font-size: 0.8rem; color: rgba(248,237,217,0.25); }

/* === Legal Pages (Privacy, Terms) === */
.legal { background: var(--midnight-bg); padding-top: 60px; }
.legal h2 { text-align: left; margin-bottom: 4px; }

.legal-back {
  display: inline-block;
  color: var(--accent);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.legal-updated {
  color: var(--cream-muted);
  font-size: 0.85rem;
  margin-bottom: 40px;
}

.legal-content {
  max-width: 720px;
  color: var(--cream-muted);
  font-size: 0.95rem;
  line-height: 1.75;
}

.legal-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--cream);
  margin-top: 32px;
  margin-bottom: 8px;
}

.legal-content p { margin-bottom: 16px; }

.legal-content ul {
  list-style: disc;
  padding-left: 24px;
  margin-bottom: 16px;
}

.legal-content li { margin-bottom: 6px; }

.legal-content a { color: var(--accent); }

/* === Responsive === */
@media (max-width: 900px) {
  .hero {
    flex-direction: column;
    text-align: center;
    gap: 48px;
    min-height: auto;
    padding: 60px 24px;
  }

  .hero-content { max-width: 100%; }
  .hero-icon { margin: 0 auto 24px; }
  .subtitle { margin: 0 auto 32px; }

  .steps { grid-template-columns: 1fr; gap: 48px; }

  .mode-row,
  .mode-row-reverse {
    flex-direction: column;
    gap: 32px;
    text-align: center;
  }

  .mode-text h3 { text-align: center; }

  .customisation-content { flex-direction: column; text-align: center; }
  .customisation-text h2 { text-align: center; }
  .customisation-list { align-items: center; }

  .features-grid { grid-template-columns: repeat(2, 1fr); }
  .quotes-grid { grid-template-columns: 1fr; }
  .modes-extra-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .hero h1 { font-size: 2.5rem; }
  .section { padding: 64px 20px; }
  .section h2 { font-size: 1.8rem; }
  .features-grid { grid-template-columns: 1fr; gap: 16px; }
  .footer-links { flex-direction: column; gap: 16px; align-items: center; }
  /* Scale board down by reducing the cell size variable */
  .chess-board { --cs: 60px; }
  .modes-extra-grid { grid-template-columns: 1fr 1fr; gap: 20px; }
  .phone-frame-small { width: 200px; }
  .screenshot-scroll .phone-frame { width: 200px; }
  .screenshot-scroll { padding: 0 20px 20px; gap: 16px; }
}
