/* =========================================================
   UltraTools AI — Flip7 design system
   Retro-playful teal · coral · gold. Bold, joyful, tactile.
   Spec values are in rpx (750rpx = phone width); 1rpx ≈ 0.5px here.
   ========================================================= */

/* ============ TOKENS ============ */
:root {
  /* Brand palette */
  --teal: #2BA8A2;            /* Primary: main UI, avatars, progress */
  --teal-light: #3CC4BD;      /* Hover states, lighter accents */
  --teal-dark: #17766F;       /* Deep backgrounds, text on light surfaces (4.9:1 on --teal-bg, passes WCAG AA) */
  --teal-bg: #E8F6F5;         /* Subtle teal tint */
  --gold: #FFD23F;            /* CTAs, highlights, winners */
  --gold-light: #FFE47A;
  --gold-dark: #E6B800;
  --coral: #EF6C4A;           /* BOOM, warnings, rank #3 */
  --coral-light: #FF8A6A;
  --coral-dark: #D45233;
  --cream: #FFF8E7;           /* Input surfaces, banners */
  --cream-dark: #F3E5BF;      /* Ribbon tails */
  --sky: #5DADE2;             /* Bonus / info */
  --silver: #A9B7C0;
  --success: #27AE60;
  --error: #E74C3C;
  --warning: var(--gold-dark);
  --ink: #173B39;             /* Outlines & strokes on retro elements */

  /* Semantic surfaces (aliases keep tool.css working) */
  --bg: #EFF8F7;              /* Surface base */
  --bg-alt: var(--teal-bg);
  --surface: #FFFFFF;         /* Surface card */
  --input-bg: var(--cream);
  --text: #173B39;
  --text-2: #4F6F6C;
  --neutral: #52726F;
  --border: #D3EBE9;
  --border-strong: #A9DAD6;
  --chip-bg: var(--teal-bg);
  --chip-text: var(--teal-dark);
  --primary: var(--teal);
  --primary-hover: var(--teal-dark);
  --link: var(--teal-dark);
  --secondary: var(--gold);
  --dot: rgba(30, 140, 134, .16);

  /* Type: system stack, extra-bold headlines */
  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-body: var(--font-display);
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, "Liberation Mono", monospace;
  --fs-display: 60px;         /* 72rpx, scaled for desktop */
  --fs-headline: 44px;        /* h1 48rpx */
  --fs-section: 34px;         /* h2 36rpx */
  --fs-subhead: 22px;         /* h3 32rpx */
  --fs-body: 15px;            /* body 28rpx */
  --fs-small: 13px;           /* sm 24rpx */
  --fs-caption: 12px;         /* xs 20rpx */
  --fs-overline: 12px;
  --track-head: .02em;
  --track-wide: .14em;

  /* Spacing — base unit 8rpx */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 12px;
  --sp-lg: 16px;
  --sp-xl: 24px;

  /* Radius */
  --r-sm: 4px;                /* 8rpx: tags, inputs */
  --r-md: 8px;                /* 16rpx: cards, buttons, inputs */
  --r-lg: 12px;               /* 24rpx: feature cards, panels */
  --r-xl: 16px;               /* 32rpx: hero cards, modals, logo */
  --r-round: 999px;
  --r-tag: var(--r-sm);
  --r-control: var(--r-md);
  --r-panel: var(--r-md);
  --r-card: var(--r-lg);
  --r-full: var(--r-round);

  /* Elevation — colored glow system */
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, .08);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, .12);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, .16);
  --shadow-card: 0 2px 10px rgba(43, 168, 162, .10);
  --shadow-coral-glow: 0 2px 10px rgba(239, 108, 74, .35);
  --shadow-teal-glow: 0 2px 10px rgba(43, 168, 162, .30);
  --shadow-accent-glow: 0 2px 10px rgba(255, 210, 63, .40);
  --shadow-sky-glow: 0 2px 8px rgba(93, 173, 226, .30);
  --shadow-focus: 0 0 0 3px rgba(43, 168, 162, .18);
  --shadow-hover: 0 6px 22px rgba(43, 168, 162, .18);
  --shadow-primary: var(--shadow-teal-glow);
  --ring: var(--shadow-focus);

  /* Motion: micro-interactions stay under 500ms */
  --bounce: cubic-bezier(.34, 1.56, .64, 1);
  --ease: 200ms ease;
  --ease-bounce: 320ms var(--bounce);
}

:root[data-theme="dark"] {
  --bg: #0D2422;
  --bg-alt: #12302E;
  --surface: #143533;
  --input-bg: #1A3D3A;
  --text: #EAF7F6;
  --text-2: #A3C9C5;
  --neutral: #8DB5B0;
  --border: #22504C;
  --border-strong: #2E6662;
  --chip-bg: #1A403D;
  --chip-text: #9BE3DE;
  --link: var(--teal-light);
  --cream-dark: #CDBF97;
  --dot: rgba(156, 227, 222, .12);
  --shadow-card: 0 2px 12px rgba(0, 0, 0, .35);
  --shadow-hover: 0 8px 26px rgba(0, 0, 0, .45);
  --shadow-focus: 0 0 0 3px rgba(60, 196, 189, .32);
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ============ BASE ============ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 800; letter-spacing: var(--track-head); color: var(--text); }
p { font-weight: 400; }
::selection { background: var(--gold-light); color: var(--ink); }

:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; box-shadow: var(--shadow-focus); border-radius: var(--r-md); }

.container { width: 100%; max-width: 1240px; margin-inline: auto; padding-inline: 24px; }
.center { text-align: center; margin-top: 40px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: var(--fs-caption); }
.skip {
  position: absolute; left: 16px; top: -64px; z-index: 200;
  background: var(--gold); color: var(--ink); font-weight: 800; padding: 8px 18px; border-radius: var(--r-round);
}
.skip:focus { top: 16px; }

/* ============ TYPE ============ */
.display { font-size: var(--fs-display); line-height: 1.05; letter-spacing: .01em; }
.h-headline { font-size: var(--fs-headline); line-height: 1.1; }
.h-section { font-size: var(--fs-section); line-height: 1.15; }
.overline {
  display: inline-flex; align-items: center; gap: 10px; margin-bottom: 14px;
  font-size: var(--fs-overline); font-weight: 800; letter-spacing: var(--track-wide); text-transform: uppercase;
  color: var(--teal-dark);
}
:root[data-theme="dark"] .overline { color: var(--teal-light); }
/* Emoji lives in its own box so every icon aligns the same way */
.sec-icon {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center;
  border-radius: var(--r-md); background: var(--cream); border: 2px solid var(--ink);
  font-size: 16px; line-height: 1; letter-spacing: 0;
  box-shadow: 2px 2px 0 var(--ink); transform: rotate(-4deg);
}
.sub { margin-top: 12px; color: var(--text-2); font-size: 16px; }
.muted-line { color: var(--teal-dark); }
.brand-hl { color: var(--gold-dark); }
.link { color: var(--link); font-weight: 700; text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 2px; text-underline-offset: 3px; transition: text-decoration-color var(--ease); }
.link:hover { text-decoration-color: currentColor; }
.link-plain { color: var(--link); font-weight: 700; }
.link-plain:hover { color: var(--teal); }

/* ============ BUTTONS — pill, 72rpx min height, bounce ============ */
.btn {
  position: relative; isolation: isolate; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 20px; border-radius: var(--r-round);
  font-size: 14px; font-weight: 800; letter-spacing: .02em; white-space: nowrap;
  border: 2px solid transparent;
  transition: transform var(--ease-bounce), background-color var(--ease), border-color var(--ease), box-shadow var(--ease), color var(--ease);
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: scale(.95); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn-lg { min-height: 50px; padding: 0 28px; font-size: 15px; }

/* Primary — gold CTA with gloss */
.btn-primary {
  color: var(--ink); border-color: var(--gold-dark);
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 55%, var(--gold-dark) 100%);
  box-shadow: var(--shadow-accent-glow);
}
.btn-primary::before {
  content: ""; position: absolute; z-index: -1; left: 10%; right: 10%; top: 2px; height: 45%;
  border-radius: var(--r-round); background: linear-gradient(180deg, rgba(255, 255, 255, .7), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.btn-primary:hover { box-shadow: 0 4px 18px rgba(255, 210, 63, .6); filter: saturate(1.08); }

/* Secondary — teal outline */
.btn-secondary { background: var(--surface); border-color: var(--teal); color: var(--teal-dark); }
.btn-secondary:hover { background: var(--teal-bg); box-shadow: var(--shadow-teal-glow); }
:root[data-theme="dark"] .btn-secondary { color: var(--teal-light); }
:root[data-theme="dark"] .btn-secondary:hover { background: var(--chip-bg); }

/* Teal solid */
.btn-teal { background: linear-gradient(180deg, var(--teal-light), var(--teal)); color: #fff; border-color: var(--teal-dark); box-shadow: var(--shadow-teal-glow); }
.btn-teal:hover { background: var(--teal-dark); }

/* On teal backgrounds */
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { color: var(--text); background: var(--teal-bg); }
.btn-light { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .75); }
.btn-light:hover { background: rgba(255, 255, 255, .22); box-shadow: 0 2px 14px rgba(255, 255, 255, .25); }

/* State buttons from the game: BOOM (coral) and Flip7 bonus (sky) */
.btn-boom { background: var(--surface); color: var(--coral-dark); border-color: var(--coral); }
.btn-boom:hover, .btn-boom.is-active { background: var(--coral); color: #fff; box-shadow: var(--shadow-coral-glow); }
.btn-boom.is-active { animation: boom-pulse 2s ease-in-out infinite; }
.btn-flip { background: var(--surface); color: #2E86C1; border-color: var(--sky); }
.btn-flip:hover, .btn-flip.is-active { background: var(--sky); color: #fff; box-shadow: var(--shadow-sky-glow); }

.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: var(--r-round); color: var(--text-2);
  transition: background-color var(--ease), color var(--ease), transform var(--ease-bounce);
}
.icon-btn:hover { background: var(--teal-bg); color: var(--text); transform: rotate(-8deg) scale(1.06); }
.icon-btn:active { transform: scale(.92); }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }

/* ============ NAV ============ */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(180deg, var(--teal) 0%, var(--teal-dark) 100%);
  border-bottom: 3px solid var(--ink);
  box-shadow: 0 2px 12px rgba(23, 59, 57, .18);
  color: #fff;
}
.nav-inner { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 64px; gap: 16px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 18px; letter-spacing: .02em; justify-self: start; }
.logo-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: var(--r-md); background: var(--gold); color: var(--ink);
  border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink);
  transform: rotate(-6deg); transition: transform var(--ease-bounce);
}
.logo:hover .logo-mark { transform: rotate(6deg) scale(1.06); }
.nav .brand-hl, .footer .brand-hl { color: var(--gold); }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  padding: 8px 14px; border-radius: var(--r-round);
  font-size: 14px; font-weight: 700; color: rgba(255, 255, 255, .88);
  transition: background-color var(--ease), color var(--ease), transform var(--ease-bounce);
}
.nav-links a:hover { background: rgba(255, 255, 255, .16); color: #fff; transform: translateY(-1px); }
.nav-links a[aria-current="page"] { background: var(--cream); color: var(--teal-dark); }
.nav-actions { display: flex; align-items: center; gap: 8px; justify-self: end; }
.nav .icon-btn { color: #fff; }
.nav .icon-btn:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.nav :focus-visible { outline-color: var(--gold); }
.menu-btn { display: none; }

/* Language switcher */
.lang-menu { position: relative; }
.nav .lang-btn { width: auto; gap: 6px; padding: 0 10px; grid-auto-flow: column; font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.nav .lang-btn:hover { transform: none; }
.lang-list {
  position: absolute; top: calc(100% + 10px); inset-inline-end: 0; z-index: 120; min-width: 168px; padding: 6px;
  background: var(--surface); border: 2px solid var(--ink); border-radius: var(--r-md); box-shadow: 3px 3px 0 var(--ink);
}
.lang-list a {
  display: block; padding: 8px 12px; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 700; color: var(--text); transition: background-color var(--ease);
}
.lang-list a:hover { background: var(--teal-bg); }
.lang-list a[aria-current="true"] { background: var(--cream); color: var(--ink); }
.lang-list a[aria-current="true"]::after { content: " ✓"; color: var(--teal-dark); }

/* ============ HERO ============ */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  padding: 72px 0 96px; text-align: center; color: #fff;
  background:
    radial-gradient(ellipse 60% 55% at 50% 30%, var(--teal-light) 0%, transparent 70%),
    linear-gradient(180deg, var(--teal) 0%, var(--teal-dark) 100%);
  --dot: rgba(255, 255, 255, .16);
  --dot-active: 255, 210, 63;
}
:root[data-theme="dark"] .hero {
  background:
    radial-gradient(ellipse 60% 55% at 50% 30%, rgba(60, 196, 189, .45) 0%, transparent 70%),
    linear-gradient(180deg, #17615D 0%, #0D2422 100%);
}
/* Scalloped bottom edge, like a card-box lid */
.hero::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 22px; z-index: 1;
  background: radial-gradient(circle at 16px 0, transparent 15px, var(--bg) 16px) 0 0 / 32px 22px repeat-x;
}
.dot-grid {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1;
  -webkit-mask-image: radial-gradient(ellipse 75% 80% at 50% 45%, #000 30%, transparent 100%);
  mask-image: radial-gradient(ellipse 75% 80% at 50% 45%, #000 30%, transparent 100%);
}
.hero-inner { display: flex; flex-direction: column; align-items: center; }
.hero h1 { margin-top: 36px; max-width: 18ch; color: #fff; text-shadow: 0 3px 0 rgba(23, 59, 57, .35); }
.hero .muted-line { color: var(--gold); }
.lead { margin-top: 20px; max-width: 580px; font-size: 18px; line-height: 1.6; color: rgba(255, 255, 255, .9); }

/* ---------- Logo lockup: fan cards + wordmark + ribbon ---------- */
.brand-lockup { position: relative; display: grid; place-items: center; padding: 40px 24px 0; }
.fan { position: absolute; left: 50%; top: 4px; width: 0; height: 150px; z-index: 0; }
.fan-card {
  position: absolute; left: -38px; bottom: 0; width: 76px; height: 108px;
  display: grid; justify-items: start; align-items: start; padding: 10px 0 0 9px; font-size: 18px; line-height: 1;
  border-radius: var(--r-lg); border: 3px solid var(--ink);
  box-shadow: 0 6px 16px rgba(23, 59, 57, .3);
  transform-origin: 50% 160%;
  transform: rotate(var(--rot)) translateY(var(--lift, 0));
  transition: transform 400ms var(--bounce);
}
.fan-card::after { content: ""; position: absolute; inset: 5px; border-radius: 7px; border: 2px dashed rgba(23, 59, 57, .3); }
.fan-card:nth-child(1) { --rot: -24deg; background: var(--sky); }
.fan-card:nth-child(2) { --rot: -12deg; background: var(--coral); }
.fan-card:nth-child(3) { --rot: 0deg;   background: var(--cream); }
.fan-card:nth-child(4) { --rot: 12deg;  background: var(--gold); }
.fan-card:nth-child(5) { --rot: 24deg;  background: var(--teal-light); }
.brand-lockup:hover .fan-card:nth-child(1) { --rot: -30deg; }
.brand-lockup:hover .fan-card:nth-child(2) { --rot: -15deg; }
.brand-lockup:hover .fan-card:nth-child(3) { --lift: -6px; }
.brand-lockup:hover .fan-card:nth-child(4) { --rot: 15deg; }
.brand-lockup:hover .fan-card:nth-child(5) { --rot: 30deg; }

.wordmark {
  position: relative; z-index: 1; margin-top: 96px; padding: 14px 26px 14px 28px;
  display: inline-flex; align-items: center; gap: 8px;
  transform: rotate(-3deg);
}
.wordmark-plate {
  position: absolute; inset: 0; z-index: -1;
  background: var(--cream); border: 3px solid var(--ink); border-radius: var(--r-md);
  transform: skewX(-6deg); box-shadow: 5px 5px 0 var(--ink);
}
.wm-word {
  font-size: 44px; font-weight: 800; letter-spacing: .04em; line-height: 1; color: var(--teal-dark);
  text-shadow: 0 2px 0 rgba(255, 255, 255, .9);
}
.wm-big {
  display: inline-block; font-size: 76px; font-weight: 800; line-height: .9; color: var(--gold);
  transform: rotate(5deg); margin: -22px -10px -22px 0;
  text-shadow:
    -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink),
    0 -2px 0 var(--ink), 0 2px 0 var(--ink), -2px 0 0 var(--ink), 2px 0 0 var(--ink),
    4px 5px 0 var(--ink);
}

/* Retro folded ribbon */
.ribbon-wrap { position: relative; z-index: 2; margin-top: 18px; }
.ribbon {
  position: relative; display: inline-block; padding: 7px 26px;
  background: var(--cream); border: 2px solid var(--ink); border-radius: 3px;
  font-size: 13px; font-weight: 800; letter-spacing: .3em; text-transform: uppercase; color: var(--teal-dark);
  white-space: nowrap;
}
.ribbon::before, .ribbon::after {
  content: ""; position: absolute; z-index: -1; top: 4px; bottom: -6px; width: 30px;
  background: var(--cream-dark); border: 2px solid var(--ink);
}
.ribbon::before { left: -20px; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 38% 50%); }
.ribbon::after { right: -20px; clip-path: polygon(0 0, 100% 0, 62% 50%, 100% 100%, 0 100%); }

/* ---------- Search ---------- */
.search {
  margin-top: 36px; width: min(580px, 100%); height: 56px;
  display: flex; align-items: center; gap: 12px; padding: 0 10px 0 20px;
  background: var(--cream); border: 3px solid var(--ink); border-radius: var(--r-round);
  color: var(--teal-dark); box-shadow: 0 5px 0 var(--ink), 0 10px 24px rgba(23, 59, 57, .25);
  transition: box-shadow var(--ease), transform var(--ease-bounce);
}
.search:focus-within { transform: translateY(-2px); box-shadow: 0 7px 0 var(--ink), 0 0 0 5px rgba(255, 210, 63, .55); }
.search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent;
  font: inherit; font-size: 15px; font-weight: 600; color: var(--ink);
}
.search input:focus-visible { outline: none; box-shadow: none; }
.search input::placeholder { color: #7C8F8D; font-weight: 500; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.kbd {
  flex: none; font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--ink);
  padding: 3px 10px; border: 2px solid var(--ink); border-radius: var(--r-round); background: var(--gold);
}

.hero-cta { margin-top: 28px; display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.trust { margin-top: 28px; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; font-size: var(--fs-small); font-weight: 700; color: #fff; }
.trust li {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px;
  border-radius: var(--r-round); background: rgba(23, 59, 57, .22); border: 1px solid rgba(255, 255, 255, .25);
}
.trust svg { color: var(--gold); }

/* ============ SECTIONS ============ */
.section { padding-block: 72px; }
.section-head {
  max-width: 680px; margin: 0 auto 44px; padding-bottom: 24px; text-align: center;
  border-bottom: 2px dashed var(--border-strong);
}
.section-head.split {
  max-width: none; text-align: start;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap;
}
.section-head.split > div { max-width: 600px; }

/* ============ CHIPS & TAGS ============ */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 36px; padding: 0 16px; border-radius: var(--r-round);
  background: var(--surface); color: var(--teal-dark); border: 2px solid var(--border-strong);
  font-size: 13px; font-weight: 800; line-height: 32px;
  transition: background-color var(--ease), color var(--ease), border-color var(--ease), transform var(--ease-bounce), box-shadow var(--ease);
}
.chip:hover { border-color: var(--teal); transform: translateY(-2px); }
.chip:active { transform: scale(.95); }
.chip.active { background: var(--teal-dark); border-color: var(--teal-dark); color: #fff; box-shadow: var(--shadow-teal-glow); }
:root[data-theme="dark"] .chip { color: var(--chip-text); }
:root[data-theme="dark"] .chip.active { color: #fff; }
.tag {
  display: inline-block; padding: 2px 10px; border-radius: var(--r-round);
  background: var(--chip-bg); color: var(--chip-text);
  font-size: var(--fs-caption); font-weight: 800; letter-spacing: .02em;
}

/* ============ TOOL CARDS — scoring-item cards ============ */
.tools-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.tool {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border-radius: var(--r-lg);
  border-inline-start: 4px solid var(--teal-light);
  box-shadow: var(--shadow-card);
  transition: transform var(--ease-bounce), box-shadow var(--ease), border-color var(--ease), background var(--ease);
}
.tool:hover {
  transform: translateY(-4px);
  border-inline-start-color: var(--gold);
  background: linear-gradient(160deg, var(--cream) 0%, var(--surface) 55%);
  box-shadow: var(--shadow-accent-glow), var(--shadow-hover);
}
:root[data-theme="dark"] .tool:hover { background: linear-gradient(160deg, #2C3A26 0%, var(--surface) 55%); }
.tool:active { transform: scale(.98); }
.tool[hidden] { display: none; }
.tool-preview {
  position: relative; height: 120px; display: grid; place-items: center;
  background-color: var(--teal-bg);
  background-image: radial-gradient(var(--dot) 1.5px, transparent 1.5px);
  background-size: 14px 14px;
  border-bottom: 2px dashed var(--border-strong);
}
:root[data-theme="dark"] .tool-preview { background-color: var(--bg-alt); }
.tool[data-cat="image"]   { --cat: var(--coral); }
.tool[data-cat="text"]    { --cat: var(--teal); }
.tool[data-cat="extract"] { --cat: var(--sky); }
.tool[data-cat="dev"]     { --cat: var(--gold-dark); }
.tool-icon {
  width: 56px; height: 56px; display: grid; place-items: center;
  border-radius: var(--r-lg); background: var(--surface); color: var(--cat, var(--teal));
  border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
  transform: rotate(-4deg);
  transition: transform var(--ease-bounce), background-color var(--ease), color var(--ease);
}
.tool:hover .tool-icon { transform: rotate(4deg) scale(1.08); background: var(--cat, var(--teal)); color: #fff; }
.ai-badge {
  position: absolute; top: 12px; right: 12px;
  padding: 2px 10px; border-radius: var(--r-round);
  background: #2878B0; color: #fff; box-shadow: var(--shadow-sky-glow); /* darker than --sky so white text passes AA */
  font-size: 11px; font-weight: 800; letter-spacing: .1em; line-height: 18px;
}
.tool-body { display: flex; flex-direction: column; flex: 1; padding: 16px 18px 18px; }
.tool h3 { font-size: 17px; letter-spacing: .01em; }
.tool p { margin-top: 6px; flex: 1; font-size: 14px; color: var(--text-2); }
.tool-meta { margin-top: 16px; display: flex; align-items: center; justify-content: space-between; }
.open { font-size: var(--fs-small); font-weight: 800; color: var(--link); }
.open span { display: inline-block; transition: transform var(--ease-bounce); }
.tool:hover .open span { transform: translateX(4px); }
/* Blog cards reuse the tool card */
.post-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.post-card[hidden] { display: none; }
.post-card .tool-preview { height: 104px; }
.post-card .tool-preview.has-thumb { height: auto; aspect-ratio: 16 / 9; display: block; overflow: hidden; background-image: none; }
.post-thumb { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top left; transition: transform .4s ease; }
.post-card:hover .post-thumb { transform: scale(1.04); }
.post-card h3 { font-size: 18px; line-height: 1.3; }
.post-card p { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.post-badge {
  position: absolute; top: 12px; right: 12px; padding: 2px 10px; border-radius: var(--r-round);
  background: var(--gold); color: var(--ink); box-shadow: var(--shadow-accent-glow);
  font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; line-height: 18px;
}
@media (max-width: 1024px) { .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; } }
@media (max-width: 640px) { .post-grid { grid-template-columns: 1fr; gap: 14px; } }

.empty {
  margin-top: 24px; padding: 18px; text-align: center; color: var(--coral-dark); font-weight: 700;
  border: 2px dashed var(--coral); border-radius: var(--r-lg); background: var(--surface);
}

/* ============ FEATURES ============ */
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.feature {
  --accent: var(--teal-light);
  position: relative; padding: 28px; background: var(--surface);
  border-radius: var(--r-lg); border-inline-start: 4px solid var(--accent); box-shadow: var(--shadow-card);
  transition: transform var(--ease-bounce), box-shadow var(--ease);
}
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.feature:nth-child(4n + 2) { --accent: var(--gold); }
.feature:nth-child(4n + 3) { --accent: var(--coral); }
.feature:nth-child(4n + 4) { --accent: var(--sky); }
.f-icon {
  width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 18px;
  border-radius: var(--r-md); background: var(--accent); color: var(--ink);
  border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
}
.feature h3 { font-size: 18px; }
.feature p { margin-top: 8px; color: var(--text-2); }

/* ============ STEPS — podium rankings ============ */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; align-items: end; }
.step {
  --tier: var(--teal-light);
  position: relative; padding: 28px 24px 26px; background: var(--surface);
  border-radius: var(--r-lg); border-inline-start: 4px solid var(--tier); box-shadow: var(--shadow-card);
}
.step-num {
  position: relative; display: inline-grid; place-items: center; width: 28px; height: 28px; margin-bottom: 18px;
  border-radius: var(--r-round); font-size: 13px; font-weight: 800; color: var(--ink);
  background: linear-gradient(145deg, var(--teal-light), var(--teal)); border: 2px solid var(--ink);
}
.step h3 { font-size: var(--fs-subhead); line-height: 1.2; }
.step p { margin-top: 8px; color: var(--text-2); max-width: 340px; }
/* 1st — gold winner card */
.step:nth-child(1) {
  --tier: var(--gold);
  background: linear-gradient(160deg, var(--cream) 0%, var(--surface) 70%);
  box-shadow: var(--shadow-accent-glow);
  padding-top: 40px;
}
:root[data-theme="dark"] .step:nth-child(1) { background: linear-gradient(160deg, #3A3A22 0%, var(--surface) 70%); }
.step:nth-child(1)::before {
  content: ""; position: absolute; inset: -5px; pointer-events: none;
  border: 3px solid var(--gold); border-radius: calc(var(--r-lg) + 5px);
  box-shadow: 0 0 18px rgba(255, 210, 63, .55);
  animation: glow-pulse 2s ease-in-out infinite;
}
.step:nth-child(1)::after {
  content: "👑"; position: absolute; top: -20px; left: 24px; font-size: 30px; line-height: 1;
  animation: crown-bounce 1.5s ease-in-out infinite;
}
.step:nth-child(1) .step-num { width: 34px; height: 34px; background: linear-gradient(145deg, var(--gold-light), var(--gold-dark)); }
/* 2nd — silver */
.step:nth-child(2) { --tier: var(--silver); border-inline-start-width: 4px; }
.step:nth-child(2) .step-num { width: 32px; height: 32px; background: linear-gradient(145deg, #F1F4F6, var(--silver)); }
.step:nth-child(2) .step-num::after,
.step:nth-child(3) .step-num::after { content: "🥈"; position: absolute; top: 2px; left: calc(100% + 8px); font-size: 20px; line-height: 1; }
/* 3rd — bronze (coral) */
.step:nth-child(3) { --tier: var(--coral); }
.step:nth-child(3) .step-num { width: 30px; height: 30px; background: linear-gradient(145deg, var(--coral-light), var(--coral-dark)); color: #fff; }
.step:nth-child(3) .step-num::after { content: "🥉"; }
.step:nth-child(3) h3 { color: var(--coral-dark); }
:root[data-theme="dark"] .step:nth-child(3) h3 { color: var(--coral-light); }

/* ============ FAQ ============ */
.faq-wrap { display: grid; grid-template-columns: 5fr 7fr; gap: 56px; align-items: start; }
.faq-intro { position: sticky; top: 100px; }
.faq-intro .sub { max-width: 380px; }
.faq { display: grid; gap: 12px; }
.faq details {
  background: var(--surface); border-radius: var(--r-lg);
  border-inline-start: 4px solid var(--teal-light); box-shadow: var(--shadow-card);
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}
.faq details[open] {
  border-inline-start-color: var(--gold); box-shadow: var(--shadow-accent-glow);
  background: linear-gradient(160deg, var(--cream) 0%, var(--surface) 60%);
}
:root[data-theme="dark"] .faq details[open] { background: linear-gradient(160deg, #33361F 0%, var(--surface) 60%); }
.faq summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 20px; border-radius: var(--r-lg);
  font-size: 16px; font-weight: 800; color: var(--text);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; flex: none; width: 30px; height: 30px; border-radius: var(--r-round);
  background:
    linear-gradient(currentColor, currentColor) center / 12px 2.5px no-repeat,
    linear-gradient(currentColor, currentColor) center / 2.5px 12px no-repeat,
    var(--teal-bg);
  color: var(--teal-dark); transition: transform var(--ease-bounce), background-color var(--ease);
}
:root[data-theme="dark"] .faq summary::after { background-color: var(--chip-bg); color: var(--teal-light); }
.faq details[open] summary::after {
  transform: rotate(135deg);
  background:
    linear-gradient(var(--ink), var(--ink)) center / 12px 2.5px no-repeat,
    linear-gradient(var(--ink), var(--ink)) center / 2.5px 12px no-repeat,
    var(--gold);
}
.faq details p { padding: 0 64px 20px 20px; color: var(--text-2); }

/* ============ CTA — the winner card ============ */
.cta {
  position: relative; overflow: hidden; isolation: isolate; text-align: center;
  padding: 80px 24px; border-radius: var(--r-xl); border: 3px solid var(--ink);
  background:
    radial-gradient(ellipse 60% 80% at 50% 0%, rgba(60, 196, 189, .9) 0%, transparent 70%),
    linear-gradient(180deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: #fff; box-shadow: 6px 6px 0 var(--ink);
}
.cta::before {
  content: ""; position: absolute; inset: 10px; z-index: -1; pointer-events: none;
  border: 2px dashed rgba(255, 255, 255, .35); border-radius: var(--r-lg);
  animation: glow-pulse 2s ease-in-out infinite;
}
.cta h2 { color: #fff; text-shadow: 0 3px 0 rgba(23, 59, 57, .35); }
.cta .overline { color: var(--gold); }
.cta .sub { max-width: 480px; margin-inline: auto; font-size: 17px; color: rgba(255, 255, 255, .9); }
.cta-btns { margin-top: 32px; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.cta-crown { display: block; font-size: 40px; line-height: 1; margin-bottom: 8px; animation: crown-bounce 1.5s ease-in-out infinite; }

/* Confetti — 10 pieces, varied size, shape and color */
.confetti { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; top: -20px; left: var(--x); width: var(--w, 10px); height: var(--h, 14px);
  background: var(--c); border-radius: var(--br, 2px); opacity: .95;
  animation: confetti-fall var(--d, 3.8s) linear var(--delay, 0s) infinite;
}
.confetti i:nth-child(1)  { --x: 6%;  --c: var(--gold);       --d: 3.4s; --delay: -0.4s; }
.confetti i:nth-child(2)  { --x: 15%; --c: var(--coral);      --d: 4.2s; --delay: -2.1s; --w: 8px;  --h: 8px; --br: 50%; }
.confetti i:nth-child(3)  { --x: 26%; --c: var(--cream);      --d: 3.9s; --delay: -1.2s; --w: 6px;  --h: 16px; }
.confetti i:nth-child(4)  { --x: 37%; --c: var(--sky);        --d: 4.5s; --delay: -3.0s; --w: 12px; --h: 12px; --br: 3px; }
.confetti i:nth-child(5)  { --x: 48%; --c: var(--gold-light); --d: 3.2s; --delay: -0.9s; --w: 9px;  --h: 9px; --br: 50%; }
.confetti i:nth-child(6)  { --x: 59%; --c: var(--coral-light);--d: 4.0s; --delay: -2.6s; }
.confetti i:nth-child(7)  { --x: 69%; --c: var(--cream);      --d: 3.6s; --delay: -1.7s; --w: 7px;  --h: 7px; --br: 50%; }
.confetti i:nth-child(8)  { --x: 78%; --c: var(--gold);       --d: 4.3s; --delay: -3.4s; --w: 5px;  --h: 15px; }
.confetti i:nth-child(9)  { --x: 87%; --c: var(--sky);        --d: 3.7s; --delay: -0.2s; --w: 11px; --h: 8px; }
.confetti i:nth-child(10) { --x: 95%; --c: var(--coral);      --d: 4.1s; --delay: -2.3s; --w: 8px;  --h: 12px; --br: 50% 0; }

/* ============ FOOTER ============ */
.footer {
  position: relative; margin-top: 24px; padding: 72px 0 32px; color: #fff;
  background: linear-gradient(180deg, var(--teal-dark) 0%, #17706B 100%);
  border-top: 3px solid var(--ink);
}
:root[data-theme="dark"] .footer { background: linear-gradient(180deg, #123F3C 0%, #0A1D1B 100%); }
.footer-grid { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: 40px; }
.f-brand p { margin: 16px 0 12px; max-width: 300px; color: rgba(255, 255, 255, .82); font-size: 14px; }
.footer .link-plain { color: var(--gold); }
.footer .link-plain:hover { color: var(--gold-light); }
.footer h2 {
  display: inline-block; margin-bottom: 18px; padding-bottom: 6px;
  font-family: var(--font-body); font-weight: 800;
  font-size: var(--fs-overline); letter-spacing: var(--track-wide); text-transform: uppercase; color: var(--gold);
  border-bottom: 2px dashed rgba(255, 210, 63, .5);
}
.footer li + li { margin-top: 12px; }
.footer nav a { font-size: 14px; font-weight: 600; color: rgba(255, 255, 255, .82); transition: color var(--ease), padding var(--ease); }
.footer nav a:hover { color: #fff; padding-inline-start: 4px; }
.footer-bottom {
  margin-top: 48px; padding: 24px 56px 0 0; border-top: 2px dashed rgba(255, 255, 255, .25);
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  font-size: var(--fs-small); color: rgba(255, 255, 255, .7);
}

/* ============ BACK TO TOP ============ */
.to-top {
  position: fixed; right: 24px; bottom: 24px; z-index: 90;
  width: 48px; height: 48px; display: grid; place-items: center;
  border-radius: var(--r-round); border: 2px solid var(--ink);
  background: linear-gradient(180deg, var(--gold-light), var(--gold)); color: var(--ink);
  box-shadow: var(--shadow-accent-glow);
  transition: transform var(--ease-bounce), box-shadow var(--ease);
}
.to-top:hover { transform: translateY(-3px); box-shadow: 0 4px 18px rgba(255, 210, 63, .6); }
.to-top:active { transform: scale(.92); }
.to-top[hidden] { display: none; }

/* ============ TOASTS ============ */
.toasts {
  position: fixed; left: 50%; bottom: 24px; z-index: 300; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  display: inline-flex; align-items: center; gap: 8px; max-width: min(480px, calc(100vw - 32px));
  padding: 12px 20px; border-radius: var(--r-round);
  background: var(--teal-dark); color: #fff; font-size: 14px; font-weight: 700;
  border: 2px solid var(--ink); box-shadow: var(--shadow-teal-glow), var(--shadow-md);
  animation: toast-in 320ms var(--bounce);
}
.toast.error { background: var(--coral); box-shadow: var(--shadow-coral-glow); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity 200ms, transform 200ms; }

/* ============ ANIMATIONS ============ */
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.95); } }
@keyframes crown-bounce {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  25%      { transform: translateY(-8px) rotate(4deg); }
  50%      { transform: translateY(0) rotate(8deg); }
  75%      { transform: translateY(-4px) rotate(-4deg); }
}
@keyframes glow-pulse {
  0%, 100% { opacity: .5; transform: scale(1); }
  50%      { opacity: 1;  transform: scale(1.03); }
}
@keyframes boom-pulse {
  0%, 100% { border-color: var(--coral); box-shadow: 0 2px 10px rgba(239, 108, 74, .35); }
  50%      { border-color: var(--coral-dark); box-shadow: 0 2px 22px rgba(239, 108, 74, .65), 0 0 0 4px rgba(239, 108, 74, .18); }
}
@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(520px) rotate(720deg); }
}

/* ============ REVEAL ============ */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .45s ease, transform .45s var(--bounce); }
.js .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  *, *::before, *::after { transition-duration: .01ms !important; animation: none !important; }
  .confetti { display: none; }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1100px) {
  .tools-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  :root { --fs-display: 50px; --fs-headline: 38px; --fs-section: 30px; }
  .section { padding-block: 56px; }
  .features { grid-template-columns: repeat(2, 1fr); }
  .faq-wrap { grid-template-columns: 1fr; gap: 32px; }
  .faq-intro { position: static; }
  .footer-grid { grid-template-columns: repeat(3, 1fr); }
  .f-brand { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  .tools-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .nav-inner { grid-template-columns: auto 1fr; }
  .menu-btn { display: grid; }
  .nav-links {
    position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 4px;
    padding: 12px 16px 18px; background: var(--teal-dark);
    border-bottom: 3px solid var(--ink); box-shadow: var(--shadow-lg);
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 16px; font-size: 15px; }
  .steps { grid-template-columns: 1fr; gap: 28px; }
  .step:nth-child(1) { padding-top: 36px; }
}
@media (max-width: 640px) {
  :root { --fs-display: 36px; --fs-headline: 30px; --fs-section: 26px; --fs-subhead: 20px; }
  .container { padding-inline: 16px; }
  .section { padding-block: 44px; }
  .hero { padding: 48px 0 72px; }
  .brand-lockup { padding-top: 24px; }
  .fan { height: 120px; }
  .fan-card { width: 60px; height: 86px; left: -30px; font-size: 20px; }
  .wordmark { margin-top: 76px; padding: 10px 18px 10px 20px; }
  .wm-word { font-size: 28px; }
  .wm-big { font-size: 52px; }
  .ribbon { padding: 6px 16px; font-size: 11px; letter-spacing: .18em; }
  .ribbon::before { left: -16px; width: 22px; }
  .ribbon::after { right: -16px; width: 22px; }
  .lead { font-size: 16px; }
  .search { height: 52px; }
  .section-head { margin-bottom: 32px; }
  .tools-grid { grid-template-columns: 1fr; gap: 14px; }
  .features { grid-template-columns: 1fr; }
  .feature { padding: 22px; }
  .cta { padding: 56px 20px; }
  .kbd { display: none; }
  .nav-cta { display: none; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 32px; }
  .footer-bottom { flex-direction: column; align-items: flex-start; }
  .faq details p { padding-inline-end: 20px; }
}

/* ============ RIGHT-TO-LEFT (Arabic) ============ */
/* Layout uses logical properties (inline-start/end), so most of the page mirrors on its own. */
[dir="rtl"] { --track-head: 0; }
/* Letter spacing breaks the joins between Arabic letters */
[dir="rtl"] body, [dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3, [dir="rtl"] h4,
[dir="rtl"] .overline, [dir="rtl"] .ribbon, [dir="rtl"] .btn, [dir="rtl"] .tag, [dir="rtl"] .label, [dir="rtl"] .chip { letter-spacing: 0; }
[dir="rtl"] .display, [dir="rtl"] .h-headline, [dir="rtl"] .h-section { line-height: 1.3; }
/* Code, hashes and other machine text stay left-to-right */
[dir="rtl"] pre, [dir="rtl"] code, [dir="rtl"] kbd, [dir="rtl"] .mono, [dir="rtl"] .textarea.mono, [dir="rtl"] .input.mono,
[dir="rtl"] .tree, [dir="rtl"] .pw-text, [dir="rtl"] input[type="url"], [dir="rtl"] input[type="email"], [dir="rtl"] input[type="tel"] { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] pre, [dir="rtl"] .textarea.mono { text-align: left; }
/* The before/after slider is positioned from the left edge */
[dir="rtl"] .compare { direction: ltr; }
[dir="rtl"] .select { background-position: left 12px center; }
[dir="rtl"] .wordmark, [dir="rtl"] .logo { direction: ltr; }

/* Analytics consent banner */
.consent {
  position: fixed; inset-inline: 16px; bottom: 16px; z-index: 90; max-width: 720px; margin-inline: auto;
  display: flex; align-items: center; gap: 16px 24px; flex-wrap: wrap; justify-content: space-between;
  padding: 16px 20px; background: var(--surface); color: var(--text); border: 2px solid var(--border-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-card);
}
.consent[hidden] { display: none; }
.consent p { margin: 0; flex: 1 1 320px; font-size: 14px; line-height: 1.55; }
.consent a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
.consent-actions { display: flex; gap: 10px; }
.consent .btn { cursor: pointer; padding-block: 8px; }
.consent .btn-secondary { background: var(--chip-bg); color: var(--chip-text); border: 0; border-radius: var(--r-round); padding-inline: 18px; font-weight: 800; }
.consent-open { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
