/* ─────────────────────────────────────────────────────────────
   TapWise: Brain Reflex — legal & support site
   Tokens mirror lib/core/theme/app_colors.dart (AppColorPalette.casual).
   One look, no dark mode — the same deliberate decision as the app.
   ───────────────────────────────────────────────────────────── */

@font-face {
  font-family: 'Palamecia Titling';
  src: url('palamecia-titling.otf') format('opentype');
  font-weight: 400;
  font-display: swap;
}

:root {
  --sky-top: #7ec8f5;
  --sky-bottom: #3e63c7;
  --primary: #ffc531;
  --primary-variant: #e08a00;
  --navy: #1b2a4a;
  --navy-soft: #3d4c6b;
  --navy-faint: #6b7794;
  --surface: #ffffff;
  --surface-tint: #f5f8ff;
  --line: #e2e8f5;
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --shadow-card: 0 18px 44px rgba(16, 30, 66, 0.16);
  --shadow-chunky: 0 6px 0 var(--primary-variant);
  --measure: 74ch;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  font-size: 17px;
  line-height: 1.72;
  color: var(--navy);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 62%,
      #2f4ba3 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* Language switching: only the active language's nodes are shown. The
   attribute lives on <html>, so a block is hidden before first paint —
   no flash of the wrong language. */
html[data-lang='tr'] [data-lang='en'],
html[data-lang='en'] [data-lang='tr'] {
  display: none !important;
}

/* ── Display type ────────────────────────────────────────── */

.display {
  font-family: 'Palamecia Titling', Impact, 'Arial Black', sans-serif;
  font-weight: 400;
  letter-spacing: 0.03em;
  line-height: 1.12;
  text-transform: uppercase;
  color: var(--primary);
  /* Stroke-behind-fill outline, the same chunky comic look OutlinedText
     paints in the app. */
  -webkit-text-stroke: 0.055em var(--navy);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 rgba(27, 42, 74, 0.35);
}

/* ── Top bar ─────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(30, 52, 116, 0.82);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.topbar__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  margin-right: auto;
}

.brand img {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
}

.brand__name {
  font-family: 'Palamecia Titling', Impact, sans-serif;
  font-size: 19px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  line-height: 1.1;
}

.brand__sub {
  display: block;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: var(--primary);
  text-transform: uppercase;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.nav a {
  color: rgba(255, 255, 255, 0.86);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 600;
  padding: 8px 13px;
  border-radius: 999px;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.nav a[aria-current='page'] {
  background: var(--primary);
  color: var(--navy);
}

/* ── Language toggle ─────────────────────────────────────── */

.langswitch {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.langswitch button {
  appearance: none;
  border: 0;
  cursor: pointer;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 6px 14px;
  border-radius: 999px;
  transition: background 0.16s ease, color 0.16s ease;
}

.langswitch button[aria-pressed='true'] {
  background: var(--primary);
  color: var(--navy);
}

.langswitch button:focus-visible,
.nav a:focus-visible,
.brand:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* ── Page shell ──────────────────────────────────────────── */

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

.hero {
  padding: 56px 0 34px;
  text-align: center;
}

.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(34px, 6.4vw, 60px);
}

.hero__lede {
  max-width: 62ch;
  margin: 0 auto;
  color: rgba(255, 255, 255, 0.92);
  font-size: 17.5px;
}

.pill {
  display: inline-block;
  margin-bottom: 18px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.26);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ── Content card ────────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  padding-bottom: 64px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: clamp(26px, 4.5vw, 52px);
  overflow-wrap: break-word;
}

.card > :first-child {
  margin-top: 0;
}

.card > :last-child {
  margin-bottom: 0;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin: 0 0 30px;
  padding-bottom: 22px;
  border-bottom: 2px solid var(--line);
  font-size: 14px;
  color: var(--navy-faint);
}

.meta b {
  color: var(--navy);
  font-weight: 700;
}

/* ── Prose ───────────────────────────────────────────────── */

.prose {
  max-width: var(--measure);
}

.prose h2 {
  font-family: 'Palamecia Titling', Impact, sans-serif;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: clamp(21px, 2.6vw, 26px);
  line-height: 1.2;
  color: var(--navy);
  margin: 46px 0 14px;
  padding-top: 10px;
  border-top: 2px solid var(--line);
}

.prose h2:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 8px;
}

.prose h3 {
  font-size: 17.5px;
  font-weight: 800;
  color: var(--navy);
  margin: 28px 0 8px;
}

.prose p,
.prose li {
  color: var(--navy-soft);
}

.prose p {
  margin: 0 0 15px;
}

.prose ul,
.prose ol {
  margin: 0 0 16px;
  padding-left: 22px;
}

.prose li {
  margin-bottom: 8px;
}

.prose li::marker {
  color: var(--primary-variant);
  font-weight: 700;
}

.prose strong {
  color: var(--navy);
  font-weight: 700;
}

.prose a {
  color: #1d4ed8;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.prose a:hover {
  color: var(--primary-variant);
}

/* ── Callout ─────────────────────────────────────────────── */

.callout {
  margin: 22px 0;
  padding: 18px 22px;
  border-radius: var(--radius-md);
  background: var(--surface-tint);
  border-left: 6px solid var(--primary);
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout--warn {
  background: #fff7e6;
  border-left-color: var(--primary-variant);
}

/* ── Table ───────────────────────────────────────────────── */

.tablewrap {
  overflow-x: auto;
  margin: 20px 0 26px;
  border-radius: var(--radius-md);
  border: 2px solid var(--line);
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 560px;
  font-size: 15px;
}

thead th {
  background: var(--navy);
  color: #fff;
  text-align: left;
  font-size: 12.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 13px 16px;
  white-space: nowrap;
}

tbody td {
  padding: 13px 16px;
  border-top: 1px solid var(--line);
  vertical-align: top;
  color: var(--navy-soft);
}

tbody tr:nth-child(even) td {
  background: #fafcff;
}

tbody td:first-child {
  font-weight: 700;
  color: var(--navy);
}

/* ── Table of contents ───────────────────────────────────── */

.toc {
  position: sticky;
  top: 88px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 26px rgba(16, 30, 66, 0.14);
  padding: 20px 18px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.toc h2 {
  margin: 0 0 12px;
  font-family: 'Palamecia Titling', Impact, sans-serif;
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--navy-faint);
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: toc;
}

.toc li {
  counter-increment: toc;
  margin-bottom: 2px;
}

.toc a {
  display: block;
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 14px;
  line-height: 1.42;
  color: var(--navy-soft);
  text-decoration: none;
  transition: background 0.14s ease, color 0.14s ease;
}

.toc a::before {
  content: counter(toc) '. ';
  color: var(--primary-variant);
  font-weight: 700;
}

.toc a:hover {
  background: var(--surface-tint);
  color: var(--navy);
}

.toc a.is-active {
  background: var(--primary);
  color: var(--navy);
  font-weight: 700;
}

.toc a.is-active::before {
  color: var(--navy);
}

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 14px 28px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--primary) 0%, #f5a92a 100%);
  color: var(--navy);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.02em;
  text-decoration: none;
  border: 2.5px solid var(--navy);
  box-shadow: var(--shadow-chunky);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover {
  transform: translateY(2px);
  box-shadow: 0 4px 0 var(--primary-variant);
}

.btn:active {
  transform: translateY(6px);
  box-shadow: 0 0 0 var(--primary-variant);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 6px 0 #b9c6e4;
}

.btn--ghost:hover {
  box-shadow: 0 4px 0 #b9c6e4;
}

/* ── Home page ───────────────────────────────────────────── */

.cardgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  padding-bottom: 56px;
}

.tile {
  display: block;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 26px 24px;
  text-decoration: none;
  color: inherit;
  border: 3px solid transparent;
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.tile:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
}

.tile__icon {
  font-size: 30px;
  line-height: 1;
  margin-bottom: 12px;
}

.tile h2 {
  margin: 0 0 6px;
  font-family: 'Palamecia Titling', Impact, sans-serif;
  font-size: 20px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--navy);
}

.tile p {
  margin: 0;
  font-size: 15px;
  color: var(--navy-faint);
  line-height: 1.6;
}

.hero__actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 26px;
}

.hero__icon {
  width: 108px;
  height: 108px;
  border-radius: 26px;
  margin: 0 auto 22px;
  display: block;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.3);
}

/* ── FAQ ─────────────────────────────────────────────────── */

.faq {
  border-top: 2px solid var(--line);
}

.faq details {
  border-bottom: 2px solid var(--line);
}

.faq summary {
  cursor: pointer;
  list-style: none;
  padding: 17px 42px 17px 2px;
  font-weight: 700;
  font-size: 16.5px;
  color: var(--navy);
  position: relative;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: '+';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 26px;
  line-height: 1;
  color: var(--primary-variant);
  font-weight: 700;
}

.faq details[open] summary::after {
  content: '–';
}

.faq summary:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: -3px;
  border-radius: 8px;
}

.faq .faq__body {
  padding: 0 8px 18px 2px;
  color: var(--navy-soft);
}

.faq .faq__body > :first-child {
  margin-top: 0;
}

.faq .faq__body > :last-child {
  margin-bottom: 0;
}

/* ── Footer ──────────────────────────────────────────────── */

.footer {
  background: rgba(14, 26, 58, 0.5);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.78);
  padding: 34px 0 42px;
  font-size: 14.5px;
}

.footer__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 26px;
  align-items: center;
  justify-content: space-between;
}

.footer a {
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.4);
}

.footer a:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.footer__links {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

/* ── Skip link ───────────────────────────────────────────── */

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 100;
  background: var(--primary);
  color: var(--navy);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
}

.skip:focus {
  left: 20px;
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 940px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .toc {
    position: static;
    max-height: none;
    order: -1;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .topbar__inner {
    padding: 10px 16px;
    gap: 10px;
  }

  .brand {
    margin-right: 0;
    width: 100%;
  }

  .nav {
    order: 3;
    width: 100%;
  }

  .nav a {
    padding: 7px 11px;
    font-size: 13.5px;
  }

  .hero {
    padding: 38px 0 26px;
  }

  .footer__inner {
    justify-content: flex-start;
  }
}

@media print {
  .topbar,
  .toc,
  .footer,
  .langswitch,
  .hero__actions {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .card {
    box-shadow: none;
    padding: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    transition-duration: 0.01ms !important;
  }
}
