@layer reset, base, components, responsive, accessibility;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { scroll-behavior: smooth; color-scheme: dark; }
  body, h1, h2, h3, p { margin: 0; }
  img, svg { display: block; max-width: 100%; }
  button, a { -webkit-tap-highlight-color: transparent; }
}

@layer base {
  html { background: var(--bg); }

  body {
    min-width: 320px;
    min-height: 100vh;
    overflow-x: hidden;
    background:
      radial-gradient(70rem 46rem at 8% -8%, oklch(57% 0.09 235 / 0.24), transparent 62%),
      radial-gradient(58rem 42rem at 96% 16%, oklch(69% 0.075 72 / 0.12), transparent 58%),
      linear-gradient(154deg, oklch(16% 0.028 242) 0%, var(--bg) 48%, oklch(11% 0.018 248) 100%);
    color: var(--text);
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.65;
    font-kerning: normal;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  body::before {
    position: fixed;
    z-index: -2;
    inset: 0;
    content: "";
    pointer-events: none;
    background:
      linear-gradient(112deg, transparent 18%, oklch(90% 0.03 235 / 0.035) 43%, transparent 61%),
      radial-gradient(36rem 22rem at 52% 34%, oklch(63% 0.065 239 / 0.08), transparent 72%);
  }

  body::after {
    position: fixed;
    z-index: -1;
    inset: 0;
    content: "";
    pointer-events: none;
    opacity: 0.28;
    background-image: repeating-linear-gradient(115deg, transparent 0 18px, oklch(96% 0.01 240 / 0.012) 19px, transparent 20px 42px);
    mask-image: linear-gradient(to bottom, black, transparent 74%);
  }

  ::selection { color: oklch(16% 0.02 245); background: var(--accent-soft); }

  a { color: inherit; }

  :focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 4px;
  }

  section { scroll-margin-top: 7rem; }
}

@layer components {
  nav {
    position: fixed;
    z-index: 100;
    top: 0;
    width: 100%;
    padding: max(12px, env(safe-area-inset-top)) 12px 0;
    background: transparent;
  }

  nav .inner {
    width: min(100%, var(--page));
    min-height: 58px;
    margin: 0 auto;
    padding: 8px 10px 8px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--line);
    border-top-color: var(--line-strong);
    border-radius: var(--radius-pill);
    background: oklch(21% 0.024 244 / 0.64);
    box-shadow: 0 18px 48px oklch(5% 0.02 245 / 0.3), inset 0 1px 0 oklch(98% 0.01 230 / 0.1);
    backdrop-filter: blur(28px) saturate(138%);
    -webkit-backdrop-filter: blur(28px) saturate(138%);
  }

  .logo {
    position: relative;
    min-height: 44px;
    padding-left: 22px;
    display: inline-flex;
    align-items: center;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 650;
    letter-spacing: -0.02em;
    text-decoration: none;
  }

  .logo::before {
    position: absolute;
    top: 50%;
    left: 0;
    width: 13px;
    height: 13px;
    content: "T";
    display: grid;
    place-items: center;
    transform: translateY(-50%);
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    color: var(--text-soft);
    font-size: 7px;
    line-height: 1;
    background: var(--surface-strong);
  }

  .nav-right { display: flex; align-items: center; gap: 8px; }
  .lang-switch { display: flex; align-items: center; gap: 0; font-size: 0.75rem; }

  .lang-switch a {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--radius-pill);
    color: var(--text-muted);
    background: transparent;
    font: inherit;
    text-decoration: none;
    transition: color 140ms, background-color 140ms;
  }

  .lang-switch a.active { color: var(--text); background: oklch(92% 0.012 235 / 0.09); }
  .lang-sep { display: none; }

  .nav-dl {
    min-height: 44px;
    padding: 0 17px;
    display: inline-flex;
    align-items: center;
    border: 1px solid oklch(96% 0.01 80 / 0.7);
    border-radius: var(--radius-pill);
    color: oklch(17% 0.02 244);
    background: var(--text);
    font-size: 0.78rem;
    font-weight: 650;
    text-decoration: none;
    transition: transform 180ms var(--ease-out), background-color 180ms;
  }

  .hero {
    width: min(100%, 980px);
    margin: 0 auto;
    padding: clamp(9.5rem, 18vw, 13rem) 20px clamp(4rem, 8vw, 6.5rem);
    text-align: center;
  }

  .hero-icon {
    width: 68px;
    height: 68px;
    margin: 0 auto 34px;
    border: 1px solid var(--line-strong);
    border-radius: 21px;
    box-shadow: 0 22px 60px oklch(5% 0.02 245 / 0.42), 0 0 0 8px oklch(86% 0.03 235 / 0.035);
    transition: transform 280ms var(--ease-out), box-shadow 280ms var(--ease-out);
  }

  .hero h1 {
    max-width: 13ch;
    margin: 0 auto 28px;
    color: var(--text);
    font-family: var(--font);
    font-size: clamp(2.8rem, 8vw, 6.4rem);
    font-weight: 690;
    line-height: 0.99;
    letter-spacing: -0.07em;
    text-wrap: balance;
  }

  .hero h1 em,
  .lang-rotate .lang-word {
    color: var(--accent-soft);
    font-style: normal;
    font-weight: 500;
  }

  .hero-phrase { display: inline; }
  .hero-phrase em { margin-inline: 0.08em; }
  .hero-phrase .lang-rotate { margin-inline-start: 0.08em; }

  .hero .sub {
    max-width: 40rem;
    margin: 0 auto 36px;
    color: var(--text-soft);
    font-size: clamp(1rem, 1.6vw, 1.16rem);
    font-weight: 400;
    line-height: 1.8;
    text-wrap: balance;
  }

  .dl-buttons { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }

  .dl-btn {
    min-height: 52px;
    padding: 0 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid oklch(96% 0.01 80 / 0.82);
    border-radius: var(--radius-pill);
    color: oklch(16% 0.02 244);
    background: var(--text);
    box-shadow: 0 12px 34px oklch(5% 0.02 245 / 0.26), inset 0 1px 0 white;
    font-size: 0.9rem;
    font-weight: 650;
    text-decoration: none;
    transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out), background-color 200ms;
  }

  .dl-btn svg { width: 17px; height: 17px; fill: currentColor; }

  .dl-btn-secondary {
    border-color: var(--line);
    color: var(--text-soft);
    background: var(--surface);
    box-shadow: inset 0 1px 0 oklch(98% 0.01 235 / 0.1);
    backdrop-filter: blur(20px) saturate(130%);
    -webkit-backdrop-filter: blur(20px) saturate(130%);
  }

  .dl-btn.primary-platform { order: -1; }
  .dl-meta { margin-top: 15px; color: var(--text-muted); font-size: 0.77rem; }

  .qr-section { margin-top: 24px; display: flex; justify-content: center; opacity: 0.72; }
  .qr-box { display: flex; flex-direction: column; align-items: center; gap: 10px; }
  .qr-img { width: 96px; height: 96px; padding: 6px; border: 1px solid var(--line); border-radius: 18px; background: var(--text); }
  .qr-label { color: var(--text-muted); font-size: 0.75rem; }

  .demo-stage { width: min(calc(100% - 32px), 900px); margin: 0 auto; padding: 0; }

  .demo-box {
    position: relative;
    min-height: 228px;
    overflow: hidden;
    padding: 66px clamp(22px, 6vw, 58px) 38px;
    border: 1px solid var(--line);
    border-top-color: var(--line-strong);
    border-radius: var(--radius-lg);
    color: var(--text);
    background:
      linear-gradient(140deg, oklch(91% 0.02 235 / 0.1), transparent 34%),
      oklch(24% 0.03 244 / 0.58);
    box-shadow: 0 36px 90px oklch(5% 0.02 245 / 0.42), inset 0 1px 0 oklch(98% 0.01 235 / 0.11);
    backdrop-filter: blur(34px) saturate(145%);
    -webkit-backdrop-filter: blur(34px) saturate(145%);
  }

  .demo-box::before {
    position: absolute;
    top: 21px;
    left: 24px;
    content: "TranslateFlow";
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 550;
    letter-spacing: 0.02em;
  }

  .demo-box::after {
    position: absolute;
    right: -10%;
    bottom: -90%;
    width: 380px;
    height: 380px;
    content: "";
    border-radius: 50%;
    background: radial-gradient(circle, oklch(71% 0.09 237 / 0.14), transparent 66%);
    pointer-events: none;
  }

  .demo-input,
  .demo-output {
    position: relative;
    z-index: 1;
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: clamp(1.12rem, 2.7vw, 1.55rem);
    font-weight: 480;
    letter-spacing: -0.02em;
  }

  .demo-input { margin-bottom: 20px; }
  .demo-input .text { color: var(--text-soft); }
  .demo-input .cursor { width: 2px; height: 1.4em; margin-left: 1px; background: var(--accent); animation: blink 900ms step-end infinite; }
  .demo-divider { position: relative; z-index: 1; height: 1px; margin-bottom: 20px; background: var(--line); }
  .demo-output .result { color: var(--text); font-size: inherit; font-weight: 500; }

  .demo-output .key {
    min-width: 42px;
    padding: 5px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    color: var(--text-soft);
    background: var(--surface-strong);
    box-shadow: inset 0 -2px 0 oklch(5% 0.02 245 / 0.3);
    font-size: 0.7rem;
    font-weight: 650;
    text-align: center;
    transition: transform 120ms, background-color 120ms;
  }

  .demo-output .key.pressed { transform: translateY(2px) scale(0.96); background: var(--bg-raised); }

  .pain, .features, .faq, .changelog {
    width: min(100%, var(--page));
    margin: 0 auto;
    padding: clamp(6rem, 12vw, 10rem) 20px 0;
  }

  .pain h2, .features h2, .audience h2, .faq h2, .changelog h2, .cta h2 {
    max-width: 18ch;
    color: var(--text);
    font-family: var(--font);
    font-size: clamp(2rem, 4.4vw, 3.8rem);
    font-weight: 630;
    line-height: 1.08;
    letter-spacing: -0.055em;
    text-align: left;
    text-wrap: balance;
  }

  .pain h2, .features h2, .faq h2, .changelog h2 { margin-bottom: clamp(34px, 6vw, 64px); }
  .pain-grid, .feature-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }

  .pain-item {
    min-height: 145px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: inset 0 1px 0 oklch(98% 0.01 235 / 0.08);
    backdrop-filter: blur(22px) saturate(130%);
    -webkit-backdrop-filter: blur(22px) saturate(130%);
    transition: transform 220ms var(--ease-out), background-color 220ms;
  }

  .pain-item .before { margin-bottom: 9px; color: var(--text-muted); font-size: 0.88rem; text-decoration: line-through; text-decoration-color: oklch(69% 0.04 30 / 0.64); }
  .pain-item .after { color: var(--text); font-size: 1rem; font-weight: 560; }

  .feature-grid { counter-reset: features; gap: 0; }
  .feature { position: relative; min-height: 166px; padding: 26px 12px 30px 48px; border-top: 1px solid var(--line); counter-increment: features; }
  .feature::before { position: absolute; top: 27px; left: 2px; content: "0" counter(features); color: var(--accent); font-size: 0.7rem; font-variant-numeric: tabular-nums; }
  .feature h3 { margin-bottom: 8px; color: var(--text); font-size: 1.08rem; font-weight: 610; }
  .feature p { max-width: 35ch; color: var(--text-soft); font-size: 1rem; font-weight: 400; line-height: 1.7; }

  .audience { width: min(100%, 820px); margin: 0 auto; padding: clamp(6rem, 12vw, 10rem) 20px 0; text-align: left; }
  .audience h2 { margin-bottom: 32px; }
  .audience-tags { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 10px 0; }
  .audience-tags span { display: inline-flex; align-items: center; color: var(--text-soft); font-size: 1rem; }
  .audience-tags span:not(:last-child)::after { width: 3px; height: 3px; margin: 0 14px; content: ""; border-radius: 50%; background: var(--accent); opacity: 0.62; }

  .faq { width: min(100%, 920px); }
  .faq-list { border-top: 1px solid var(--line); }
  .faq-item { border-bottom: 1px solid var(--line); }
  .faq-item summary { position: relative; padding: 24px 44px 24px 0; color: var(--text); font-size: 1.05rem; font-weight: 580; cursor: pointer; list-style: none; }
  .faq-item summary::-webkit-details-marker { display: none; }
  .faq-item summary::after { position: absolute; top: 50%; right: 4px; content: "+"; transform: translateY(-50%); color: var(--accent); font-size: 1.35rem; font-weight: 350; transition: transform 180ms var(--ease-out); }
  .faq-item[open] summary::after { transform: translateY(-50%) rotate(45deg); }
  .faq-item p { max-width: 64ch; padding: 0 44px 24px 0; color: var(--text-soft); font-size: 1rem; line-height: 1.75; }

  .changelog { width: min(100%, 920px); }
  .changelog-list { position: relative; display: flex; flex-direction: column; gap: 0; }
  .changelog-list::before { position: absolute; top: 12px; bottom: 12px; left: 5px; width: 1px; content: ""; background: linear-gradient(var(--line-strong), var(--line), transparent); }
  .changelog-item { position: relative; padding: 0 0 42px 34px; background: transparent; border-radius: 0; }
  .changelog-item::before { position: absolute; top: 8px; left: 1px; width: 9px; height: 9px; content: ""; border: 2px solid var(--bg); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px var(--line-strong); }
  .changelog-ver { margin-bottom: 12px; color: var(--text); font-size: 0.95rem; font-weight: 620; }
  .changelog-date { margin-left: 8px; color: var(--text-muted); font-size: 0.76rem; font-weight: 450; font-variant-numeric: tabular-nums; }
  .changelog-item ul { padding: 0; display: flex; flex-direction: column; gap: 6px; list-style: none; }
  .changelog-item li { position: relative; padding-left: 14px; color: var(--text-soft); font-size: 1rem; line-height: 1.62; }
  .changelog-item li::before { position: absolute; left: 0; content: "·"; color: var(--accent); }
  .changelog-item li b { color: var(--text); font-weight: 600; }

  .changelog-item:nth-child(n + 3) { padding-bottom: 26px; opacity: 0.78; }
  .changelog-item:nth-child(n + 3) .changelog-ver { margin-bottom: 8px; font-size: 0.92rem; }
  .changelog-item:nth-child(n + 3) li { line-height: 1.5; }

  .cta {
    position: relative;
    width: min(calc(100% - clamp(24px, 6vw, 64px)), 920px);
    margin: clamp(6rem, 12vw, 10rem) auto 80px;
    overflow: hidden;
    padding: clamp(42px, 8vw, 76px) 22px;
    border: 1px solid var(--line);
    border-top-color: var(--line-strong);
    border-radius: var(--radius-lg);
    text-align: center;
    background: linear-gradient(145deg, oklch(91% 0.02 235 / 0.11), transparent 42%), var(--surface);
    box-shadow: 0 32px 80px oklch(5% 0.02 245 / 0.34), inset 0 1px 0 oklch(98% 0.01 235 / 0.1);
    backdrop-filter: blur(30px) saturate(140%);
    -webkit-backdrop-filter: blur(30px) saturate(140%);
  }

  .cta::before { position: absolute; top: -120px; left: 50%; width: 420px; height: 250px; content: ""; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(circle, oklch(68% 0.08 237 / 0.18), transparent 70%); pointer-events: none; }
  .cta h2 { position: relative; max-width: 18ch; margin: 0 auto 15px; text-align: center; }
  .cta p { position: relative; max-width: 42ch; margin: 0 auto 30px; color: var(--text-soft); font-size: 1rem; }
  .cta .dl-buttons, .cta .dl-meta { position: relative; }

  footer { padding: 36px 20px max(38px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--text-muted); background: oklch(10% 0.018 246 / 0.4); font-size: 0.78rem; text-align: center; }
  .footer-main, .footer-links { margin-bottom: 9px; }
  .footer-links a, .footer-icp a { min-height: 44px; display: inline-flex; align-items: center; color: var(--text-soft); text-decoration: underline; text-decoration-color: oklch(80% 0.018 83 / 0.4); text-decoration-thickness: 1px; text-underline-offset: 4px; }
  .footer-links a:visited, .footer-icp a:visited { color: var(--text-muted); }
  .footer-links span { margin: 0 6px; }
  .footer-icp { margin-top: 4px; }
  .footer-icp a { font-size: 0.74rem; }

  .lang-rotate { position: relative; min-width: 3.2em; display: inline-block; text-align: left; }
  .lang-rotate .lang-word { display: inline-block; opacity: 0; transform: translateY(0.35em); transition: opacity 220ms, transform 220ms var(--ease-out); }
  .lang-rotate .lang-word.in { opacity: 1; transform: none; }
  .lang-rotate .lang-word.out { position: absolute; left: 0; opacity: 0; transform: translateY(-0.35em); }

  @keyframes blink { 50% { opacity: 0; } }

  .anim { opacity: 0; transform: translateY(16px); transition: opacity 650ms var(--ease-out), transform 650ms var(--ease-out); }
  .anim.visible { opacity: 1; transform: none; }

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

@layer responsive {
  @media (min-width: 640px) {
    nav { padding-inline: 20px; }
    .hero { padding-inline: 32px; }
    .pain, .features, .faq, .changelog, .audience { padding-inline: 32px; }
    .pain-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
    .feature-grid { grid-template-columns: 1fr 1fr; column-gap: 40px; }
  }

  @media (min-width: 900px) {
    .feature-grid { grid-template-columns: repeat(3, 1fr); column-gap: 36px; }
    .hero h1 { max-width: 12ch; }
    .changelog-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 52px; }
    .changelog-list::before { display: none; }
    .changelog-item { padding: 28px 0; border-top: 1px solid var(--line); }
    .changelog-item::before { display: none; }
    .changelog-item:nth-child(-n + 2) { grid-column: 1 / -1; }
    .changelog-item:nth-child(n + 3) { padding-block: 22px; }
  }

  @media (max-width: 639px) {
    .logo { width: 44px; padding-left: 0; justify-content: center; }
    .logo::before { position: static; width: 24px; height: 24px; transform: none; border-radius: 8px; font-size: 12px; }
    .logo-wordmark { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
    .nav-dl { padding-inline: 14px; }
    .hero h1 { letter-spacing: -0.055em; }
    .dl-buttons { flex-direction: column; align-items: stretch; }
    .dl-btn { width: 100%; }
    .qr-section { display: none; }
    .demo-stage { width: min(calc(100% - 24px), 900px); }
    .demo-box { border-radius: 26px; }
    .demo-output { align-items: flex-start; flex-direction: column; }
    .cta { margin-bottom: 52px; border-radius: 26px; }
  }

  @media (pointer: coarse) {
    .lang-switch a { min-width: 44px; min-height: 44px; }
    .nav-dl { min-height: 44px; }
    .dl-btn { min-height: 56px; }
  }

  @media (hover: hover) {
    .hero-icon:hover { transform: translateY(-4px) rotate(-2deg); box-shadow: 0 28px 72px oklch(5% 0.02 245 / 0.5), 0 0 0 8px oklch(86% 0.03 235 / 0.055); }
    .nav-dl:hover, .dl-btn:hover { transform: translateY(-2px); }
    .dl-btn:hover { box-shadow: 0 18px 44px oklch(5% 0.02 245 / 0.35), inset 0 1px 0 white; }
    .dl-btn-secondary:hover { color: var(--text); background: var(--surface-hover); box-shadow: inset 0 1px 0 oklch(98% 0.01 235 / 0.12); }
    .pain-item:hover { transform: translateY(-3px); background: var(--surface-strong); }
    .footer-links a:hover, .footer-icp a:hover { color: var(--text-soft); }
  }
}

@layer accessibility {
  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
    .anim { opacity: 1; transform: none; }
  }

  @media (prefers-reduced-transparency: reduce) {
    nav .inner, .demo-box, .pain-item, .dl-btn-secondary, .cta { background: var(--bg-raised); backdrop-filter: none; -webkit-backdrop-filter: none; }
  }

  @media (forced-colors: active) {
    nav .inner, .demo-box, .pain-item, .cta, .dl-btn { border: 1px solid CanvasText; }
  }
}
