/* =========================================================
   Percentage Calculator — Design tokens
   Same brand system as the rest of Multi Tools: deep indigo
   base, violet→cyan gradient accent, amber highlight.
   Display: Space Grotesk. Body: Inter. Data: JetBrains Mono.
   ========================================================= */
:root {
  --bg-deep: #0b0e1a;
  --bg-elevated: #121728;
  --bg-elevated-2: #171d33;
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --glass-border: rgba(255, 255, 255, 0.12);

  --accent-violet: #7c5cff;
  --accent-cyan: #22d3ee;
  --accent-amber: #fbbf24;
  --accent-gradient: linear-gradient(135deg, var(--accent-violet), var(--accent-cyan));

  --text-primary: #edeff7;
  --text-muted: #9aa3c0;
  --text-dim: #6b7394;

  --success: #34d399;
  --danger: #fb7185;

  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Consolas", monospace;

  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --shadow-soft: 0 20px 60px -20px rgba(0, 0, 0, 0.6);

  --transition-fast: 160ms ease;
  --transition-med: 320ms cubic-bezier(0.16, 1, 0.3, 1);

  --header-h: 72px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg-deep: #f3f4fb;
  --bg-elevated: #ffffff;
  --bg-elevated-2: #f8f9fe;
  --glass: rgba(18, 23, 42, 0.035);
  --glass-strong: rgba(18, 23, 42, 0.06);
  --glass-border: rgba(18, 23, 42, 0.09);

  --text-primary: #131a2e;
  --text-muted: #4b5372;
  --text-dim: #7b849f;

  --shadow-soft: 0 20px 50px -24px rgba(20, 24, 50, 0.25);
  color-scheme: light;
}

/* =========================== Reset =========================== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: radial-gradient(ellipse 120% 80% at 50% -10%, rgba(124, 92, 255, 0.16), transparent 60%), var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition-med), color var(--transition-med);
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; margin: 0 0 0.5em; }
p { margin: 0 0 1em; color: var(--text-muted); }
a { color: inherit; }
button, input, select { font-family: inherit; }

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

.skip-link {
  position: absolute; left: 12px; top: -48px;
  background: var(--accent-violet); color: #fff; padding: 10px 16px;
  border-radius: var(--radius-sm); z-index: 1000; transition: top var(--transition-fast);
  text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 12px; }

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

/* =========================== Header =========================== */
.site-header {
  position: sticky; top: 0; z-index: 100; height: var(--header-h);
  backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
  background: rgba(11, 14, 26, 0.72); border-bottom: 1px solid var(--glass-border);
}
[data-theme="light"] .site-header { background: rgba(255, 255, 255, 0.78); }
.header-inner { max-width: 1280px; margin: 0 auto; height: 100%; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-text { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--text-primary); }
.logo-accent { background: var(--accent-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.main-nav { display: flex; gap: 28px; }
.main-nav a { text-decoration: none; color: var(--text-muted); font-size: 0.92rem; font-weight: 500; transition: color var(--transition-fast); }
.main-nav a:hover { color: var(--text-primary); }

.theme-toggle {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--glass-border); background: var(--glass);
  color: var(--text-primary); display: grid; place-items: center; cursor: pointer;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}
.theme-toggle:hover { border-color: var(--accent-violet); transform: translateY(-1px); }
.theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }

/* =========================== Breadcrumb =========================== */
.breadcrumb-bar { max-width: 1280px; margin: 0 auto; padding: 20px 24px 0; }
.breadcrumb { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0; font-size: 0.82rem; color: var(--text-dim); }
.breadcrumb li:not(:last-child)::after { content: "/"; margin-left: 8px; color: var(--text-dim); }
.breadcrumb a { text-decoration: none; color: var(--text-dim); }
.breadcrumb a:hover { color: var(--accent-cyan); }
.breadcrumb li[aria-current="page"] { color: var(--text-muted); }

/* =========================== Hero =========================== */
.hero { max-width: 1280px; margin: 0 auto; padding: 40px 24px 80px; }
.hero-intro { text-align: center; max-width: 640px; margin: 0 auto 40px; }
.eyebrow {
  display: inline-block; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-cyan); border: 1px solid rgba(34, 211, 238, 0.35); padding: 6px 14px; border-radius: 999px;
  margin-bottom: 18px; background: rgba(34, 211, 238, 0.06);
}
.hero h1 { font-size: clamp(2.2rem, 4.4vw, 3.4rem); margin-bottom: 0.4em; letter-spacing: -0.02em; }
.hero-sub { font-size: 1.08rem; color: var(--text-muted); }

/* ---- Tool shell layout: switcher sidebar + calculator panel ---- */
.tool-shell { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }

/* ---- Switcher ---- */
.calc-switcher {
  position: sticky; top: calc(var(--header-h) + 20px);
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius-lg);
  backdrop-filter: blur(20px) saturate(140%); -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: var(--shadow-soft); padding: 20px; max-height: calc(100vh - var(--header-h) - 40px); overflow-y: auto;
}
.switcher-fieldset { border: none; margin: 0; padding: 0; }
.group-label {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-dim); margin: 18px 0 8px;
}
.group-label:first-child { margin-top: 0; }
.switch-group { display: flex; flex-direction: column; gap: 6px; }

.switch-pill { display: block; cursor: pointer; }
.switch-pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-pill span {
  display: block; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 0.86rem; font-weight: 500;
  color: var(--text-muted); border: 1px solid transparent; transition: all var(--transition-fast);
}
.switch-pill:hover span { color: var(--text-primary); background: var(--glass-strong); }
.switch-pill input:checked + span {
  background: var(--accent-gradient); color: #fff; box-shadow: 0 6px 16px -6px rgba(124, 92, 255, 0.6);
}
.switch-pill input:focus-visible + span { outline: 2px solid var(--accent-cyan); outline-offset: 2px; }

/* ---- Calculator panel ---- */
.glass-panel {
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius-lg);
  backdrop-filter: blur(20px) saturate(140%); -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: var(--shadow-soft); padding: 24px;
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.panel-title { font-size: 1.3rem; margin-bottom: 4px; }
.panel-desc { font-size: 0.9rem; margin: 0; }

.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px; background: var(--glass-strong); color: var(--text-muted);
  border: 1px solid var(--glass-border); border-radius: var(--radius-sm); padding: 7px 12px; font-size: 0.82rem;
  font-weight: 500; cursor: pointer; transition: all var(--transition-fast); white-space: nowrap;
}
.ghost-btn:hover:not(:disabled) { color: var(--text-primary); border-color: var(--accent-violet); transform: translateY(-1px); }
.ghost-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- Dynamic form fields ---- */
.calc-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.78rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.field-input {
  display: flex; align-items: center; background: rgba(0,0,0,0.18); border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm); overflow: hidden; transition: border-color var(--transition-fast);
}
[data-theme="light"] .field-input { background: rgba(18,23,42,0.03); }
.field-input:focus-within { border-color: var(--accent-violet); }
.field-input input, .field-input select {
  flex: 1; min-width: 0; background: transparent; border: none; color: var(--text-primary);
  padding: 11px 12px; font-size: 0.98rem; font-family: var(--font-mono);
}
.field-input select { font-family: var(--font-body); cursor: pointer; appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239aa3c0' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.field-input input:focus, .field-input select:focus { outline: none; }
.field-input input::placeholder { color: var(--text-dim); }
.field-suffix { padding: 0 12px; color: var(--text-dim); font-family: var(--font-mono); font-size: 0.9rem; border-left: 1px solid var(--glass-border); align-self: stretch; display: flex; align-items: center; }

.field-error { color: var(--danger); font-size: 0.85rem; margin: 10px 0 0; min-height: 1.1em; }

/* ---- Ratio meter (signature element) ---- */
.ratio-meter { margin-top: 20px; }
.ratio-track {
  position: relative; height: 14px; border-radius: 999px; background: var(--glass-strong);
  border: 1px solid var(--glass-border); overflow: hidden;
}
.ratio-fill {
  position: absolute; inset: 0 auto 0 0; width: 0%; border-radius: 999px;
  background: var(--accent-gradient); transition: width 700ms cubic-bezier(0.16, 1, 0.3, 1);
}
.ratio-segments { position: absolute; inset: 0; display: flex; }
.ratio-segments .seg { height: 100%; border-right: 2px solid var(--bg-deep); }
.ratio-caption { display: flex; justify-content: flex-end; margin-top: 6px; }
#ratio-label { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-dim); }

/* ---- Result section ---- */
.result-section { margin-top: 24px; padding-top: 20px; border-top: 1px dashed var(--glass-border); }

.answer-block {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; margin-bottom: 10px;
}
.answer-label { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); font-weight: 600; }
.answer-value {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(1.8rem, 4vw, 2.6rem);
  background: var(--accent-gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
  line-height: 1.15;
}
.answer-sub { font-size: 0.88rem; color: var(--text-muted); }

.calc-line { font-family: var(--font-mono); font-size: 0.88rem; color: var(--text-muted); margin-bottom: 16px; }

.output-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.detail-card {
  background: var(--glass-strong); border: 1px solid var(--glass-border); border-radius: var(--radius-md); padding: 16px;
}
.detail-card h3 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent-cyan); margin-bottom: 10px; }
.detail-card p { margin: 0; font-size: 0.92rem; color: var(--text-muted); }
.mono-text { font-family: var(--font-mono); color: var(--text-primary) !important; }
.steps-list, .uses-list { margin: 0; padding-left: 1.15em; font-size: 0.9rem; }
.steps-list li, .uses-list li { margin-bottom: 6px; color: var(--text-muted); }

@media (prefers-reduced-motion: reduce) {
  .ratio-fill { transition: none; }
  html { scroll-behavior: auto; }
}

/* =========================== Article =========================== */
.content-article { max-width: 1280px; margin: 0 auto; padding: 20px 24px 100px; }
.article-grid { display: grid; grid-template-columns: 240px 1fr; gap: 56px; }

.toc-sticky {
  position: sticky; top: calc(var(--header-h) + 24px);
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius-md);
  padding: 18px; backdrop-filter: blur(16px);
}
.toc-sticky h2 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 10px; }
.toc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.toc-list a { text-decoration: none; color: var(--text-muted); font-size: 0.86rem; transition: color var(--transition-fast); }
.toc-list a:hover { color: var(--accent-cyan); }

.article-body { max-width: 760px; }
.article-body h2 { font-size: 1.5rem; margin-top: 2.2em; scroll-margin-top: calc(var(--header-h) + 20px); }
.article-body section:first-child h2 { margin-top: 0; }
.article-body h3 { font-size: 1.12rem; margin-top: 1.5em; color: var(--text-primary); scroll-margin-top: calc(var(--header-h) + 20px); }
.article-body p, .article-body li { color: var(--text-muted); }
.article-body a { color: var(--accent-cyan); text-decoration: underline; text-underline-offset: 2px; }

.callout-formula {
  font-family: var(--font-mono); font-size: 1.02rem; color: var(--text-primary);
  background: var(--glass); border: 1px solid var(--glass-border); border-left: 3px solid var(--accent-violet);
  border-radius: var(--radius-sm); padding: 12px 16px; margin: 0 0 1em;
}

.styled-list { padding-left: 1.3em; margin: 0 0 1em; }
.styled-list li { margin-bottom: 0.55em; }
.styled-list.checklist { list-style: none; padding-left: 0; }
.styled-list.checklist li { padding-left: 1.8em; position: relative; }
.styled-list.checklist li::before {
  content: ""; position: absolute; left: 0; top: 0.15em; width: 18px; height: 18px; border-radius: 5px;
  border: 1.5px solid var(--accent-violet); background: rgba(124, 92, 255, 0.08);
}
.styled-list.checklist li::after {
  content: ""; position: absolute; left: 5px; top: 0.5em; width: 8px; height: 4px;
  border-left: 2px solid var(--accent-cyan); border-bottom: 2px solid var(--accent-cyan); transform: rotate(-45deg);
}

.table-wrap { overflow-x: auto; margin-bottom: 1em; border-radius: var(--radius-md); border: 1px solid var(--glass-border); }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--glass-border); }
th { background: var(--glass-strong); color: var(--text-primary); font-family: var(--font-display); font-weight: 600; }
tr:last-child td { border-bottom: none; }
td { color: var(--text-muted); }

.faq-item { margin-bottom: 1.4em; }
.faq-item h3 { margin-bottom: 0.35em; }

/* =========================== Footer =========================== */
.site-footer { border-top: 1px solid var(--glass-border); padding: 48px 24px 24px; }
.footer-inner { max-width: 1280px; margin: 0 auto; display: flex; justify-content: space-between; gap: 40px; flex-wrap: wrap; }
.footer-brand p { max-width: 320px; margin-top: 10px; font-size: 0.88rem; }
.footer-links h2 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 12px; }
.footer-links { display: flex; flex-direction: column; }
.footer-links a { text-decoration: none; color: var(--text-muted); font-size: 0.9rem; margin-bottom: 8px; transition: color var(--transition-fast); }
.footer-links a:hover { color: var(--accent-cyan); }
.footer-bottom { max-width: 1280px; margin: 32px auto 0; font-size: 0.8rem; color: var(--text-dim); }

/* =========================== Responsive =========================== */
@media (max-width: 1080px) {
  .tool-shell { grid-template-columns: 1fr; }
  .calc-switcher { position: static; max-height: none; }
  .switch-group { flex-direction: row; flex-wrap: wrap; }
  .switch-pill span { padding: 8px 14px; }
  .article-grid { grid-template-columns: 1fr; }
  .toc-rail { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .header-inner { padding: 0 16px; }
  .main-nav { display: none; }
  .hero { padding: 28px 16px 56px; }
  .glass-panel, .calc-switcher { padding: 16px; }
  .content-article { padding: 8px 16px 72px; }
  .breadcrumb-bar { padding: 16px 16px 0; }
  .calc-fields { grid-template-columns: 1fr; }
}

/* =========================== Print =========================== */
@media print {
  .site-header, .breadcrumb-bar, .hero-intro, .calc-switcher, .calc-form, .ratio-meter,
  .output-actions, .content-article, .site-footer, .skip-link, .panel-head { display: none !important; }
  .glass-panel { border: none; box-shadow: none; padding: 0; }
  .result-section { border: none; }
  body { background: #fff; color: #000; }
  .answer-value { -webkit-text-fill-color: #000; background: none; color: #000; }
}
