/* =============================================================
   Percentage Calculator - "Percentify" family, teal/green.
   EVERYTHING IS SCOPED UNDER .pctc - see sql-formatter.css for why.
   THEME follows the site's data-theme attribute on <html>.
   ============================================================= */

.pctc {
  --ink: #15181A; --ink-2: #4D545A; --ink-3: #828A91;
  --paper: #ECEEE9; --surface: #FFFFFF; --surface-2: #F6F7F3; --surface-3: #EFF1EC;
  --line: #DCDFD8; --line-2: #C6CABF;
  --brand: #0D6B5A; --brand-2: #13A184; --brand-soft: #DEF0EA; --brand-ink: #0A4C40;
  --neg: #BF4527; --neg-soft: #FAE7E1;
  --gold: #B8791C; --gold-soft: #F8EEDA;
  --radius: 16px; --radius-sm: 10px;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Instrument Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --shadow-sm: 0 1px 2px rgba(21,24,26,.05);
  --shadow: 0 2px 4px rgba(21,24,26,.04), 0 18px 44px -24px rgba(21,24,26,.30);
  --shadow-lg: 0 2px 6px rgba(21,24,26,.05), 0 40px 80px -40px rgba(13,107,90,.42);

  background: var(--paper); color: var(--ink); font-family: var(--body);
  font-size: 16px; line-height: 1.62; -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
[data-theme="dark"] .pctc {
  --ink: #ECEFEA; --ink-2: #A3ABA6; --ink-3: #767E7A;
  --paper: #0D100F; --surface: #161A19; --surface-2: #1D2221; --surface-3: #232928;
  --line: #2A302E; --line-2: #3B4341;
  --brand: #3FCCA9; --brand-2: #5FE0BF; --brand-soft: #0F2B26; --brand-ink: #8CEBD3;
  --neg: #F0785A; --neg-soft: #301710;
  --gold: #E0AE5A; --gold-soft: #2C2211;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 2px 4px rgba(0,0,0,.35), 0 18px 44px -24px rgba(0,0,0,.9);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.4), 0 40px 80px -40px rgba(0,0,0,1);
}

.pctc *, .pctc *::before, .pctc *::after { box-sizing: border-box }
.pctc h1, .pctc h2, .pctc h3, .pctc h4 { font-family: var(--display); margin: 0; line-height: 1.12; letter-spacing: -.025em; font-weight: 600 }
.pctc p { margin: 0 }
.pctc button, .pctc input, .pctc select { font: inherit; color: inherit }
.pctc button { cursor: pointer; background: none; border: 0 }
.pctc a { color: var(--brand); text-underline-offset: 3px }
.pctc :focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; border-radius: 6px }
.pctc .wrap { max-width: 1080px; margin: 0 auto; padding: 0 22px }
.pctc .eyebrow { font-family: var(--mono); font-size: 11.5px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3) }
.pctc .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0 }

/* ---------- in-page section nav (was a sticky site header) ---------- */
.pctc .section-nav { border-bottom: 1px solid var(--line); background: var(--surface); margin-bottom: 4px }
.pctc .section-nav__in { display: flex; align-items: center; gap: 18px; min-height: 50px; flex-wrap: wrap }
.pctc .section-nav a { text-decoration: none; color: var(--ink-2); font-size: 13.5px; font-weight: 500; padding-bottom: 2px; border-bottom: 2px solid transparent }
.pctc .section-nav a:hover { color: var(--ink); border-bottom-color: var(--line-2) }
.pctc .section-nav a.here { color: var(--brand-ink); border-bottom-color: var(--brand) }

/* ---------------- hero ---------------- */
.pctc .hero { padding: 44px 0 30px; text-align: center; position: relative; overflow: hidden }
.pctc .hero::before { content: ""; position: absolute; z-index: 0; left: 50%; top: -380px; transform: translateX(-50%); width: 900px; height: 620px; pointer-events: none; background: radial-gradient(closest-side, color-mix(in srgb, var(--brand) 16%, transparent), transparent 72%) }
.pctc .hero > * { position: relative; z-index: 1 }
.pctc .hero h1 { font-size: clamp(34px,5.2vw,54px); margin: 16px auto 14px; max-width: 16ch }
.pctc .hero h1 .pc { color: var(--brand); font-weight: 700; display: inline-block; transform: translateY(.02em) }
.pctc .hero .lede { color: var(--ink-2); max-width: 56ch; margin: 0 auto; font-size: 17px }

/* ---------------- calculator ---------------- */
.pctc .calc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; margin-top: 34px }
.pctc .tabrail { display: flex; gap: 5px; padding: 12px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); background: var(--surface-2) }
.pctc .tabrail::-webkit-scrollbar { display: none }
.pctc .tab { flex: none; padding: 9px 15px; border-radius: 999px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); white-space: nowrap; border: 1px solid transparent; transition: background .2s, color .2s, border-color .2s }
.pctc .tab:hover { color: var(--ink); background: var(--surface-3) }
.pctc .tab[aria-selected="true"] { background: var(--brand); color: #fff; border-color: transparent }
[data-theme="dark"] .pctc .tab[aria-selected="true"] { color: #0B1614 }

.pctc .stage { padding: 34px 30px 30px }
.pctc .sentence { font-family: var(--display); font-size: clamp(21px,3vw,30px); font-weight: 500; letter-spacing: -.02em; line-height: 1.85; color: var(--ink) }
.pctc .slot { font-family: var(--mono); font-size: .82em; font-weight: 500; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); border-radius: 9px; padding: 5px 10px; min-width: 3.4ch; text-align: center; transition: border-color .18s, background .18s, box-shadow .18s }
.pctc .slot:hover { border-color: var(--line-2) }
.pctc .slot:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent) }
.pctc .slot::-webkit-outer-spin-button, .pctc .slot::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0 }
.pctc .slot[type=number] { -moz-appearance: textfield }
.pctc select.slot { padding-right: 26px; cursor: pointer; text-align: left; min-width: auto; appearance: none; background-image: linear-gradient(45deg,transparent 50%,var(--ink-3) 50%),linear-gradient(135deg,var(--ink-3) 50%,transparent 50%); background-position: calc(100% - 14px) 55%, calc(100% - 9px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat }
.pctc .panel[hidden] { display: none }

/* ---------------- result ---------------- */
.pctc .result { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 34px; align-items: center; margin-top: 30px; padding-top: 28px; border-top: 1px solid var(--line) }
.pctc .res-label { font-family: var(--mono); font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3) }
.pctc .res-value { font-family: var(--display); font-weight: 700; letter-spacing: -.045em; font-size: clamp(46px,8vw,76px); line-height: 1; margin: 10px 0 0; color: var(--brand); word-break: break-word; transition: color .3s }
.pctc .res-value.neg { color: var(--neg) }
.pctc .res-value.dim { color: var(--ink-3) }
.pctc .res-value .suf { font-size: .46em; letter-spacing: -.02em; margin-left: .08em; color: var(--ink-3); font-weight: 600 }
.pctc .res-steps { margin-top: 16px; font-family: var(--mono); font-size: 13px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 14px; overflow-x: auto; white-space: nowrap }
.pctc .res-note { margin-top: 12px; font-size: 14px; color: var(--ink-2) }
.pctc .res-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap }
.pctc .mini-btn { border: 1px solid var(--line); border-radius: 8px; padding: 7px 13px; font-size: 13px; font-weight: 500; color: var(--ink-2); transition: border-color .18s, color .18s, background .18s }
.pctc .mini-btn:hover { border-color: var(--line-2); color: var(--ink); background: var(--surface-2) }

/* ---------------- hundred grid ---------------- */
.pctc .hundred { width: 264px; flex: none }
.pctc .grid100 { display: grid; grid-template-columns: repeat(10,1fr); gap: 4px; padding: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px }
.pctc .cell { position: relative; aspect-ratio: 1; border-radius: 3px; background: var(--surface-3); overflow: hidden }
[data-theme="dark"] .pctc .cell { background: #111614 }
.pctc .cell i { position: absolute; inset: 0; display: block; background: var(--brand); transform: scaleY(0); transform-origin: bottom; transition: transform .42s cubic-bezier(.22,.9,.28,1), background-color .3s }
.pctc .grid100.negative .cell i { background: var(--neg) }
.pctc .hundred-cap { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 11px; font-family: var(--mono); font-size: 11.5px; color: var(--ink-3) }
.pctc .hundred-cap b { color: var(--ink); font-weight: 500 }
.pctc .overflow-tag { display: none; margin-top: 8px; font-family: var(--mono); font-size: 11.5px; color: var(--gold); background: var(--gold-soft); border-radius: 7px; padding: 5px 9px; text-align: center }
.pctc .overflow-tag.show { display: block }
.pctc .grid100.clickable .cell { cursor: pointer }
.pctc .grid100.clickable .cell::after { content: ""; position: absolute; inset: 0; background: var(--brand); opacity: 0; transition: opacity .15s }
.pctc .grid100.clickable .cell:hover::after { opacity: .28 }
@media (max-width: 820px) { .pctc .result { grid-template-columns: 1fr; gap: 26px } .pctc .hundred { width: 100%; max-width: 300px } .pctc .stage { padding: 26px 20px 24px } .pctc .sentence { line-height: 2.05 } }

/* ---------------- sections ---------------- */
.pctc section.block { padding: 56px 0 0 }
.pctc .block-head { margin-bottom: 22px }
.pctc .block-head h2 { font-size: clamp(24px,3.4vw,32px); margin: 10px 0 8px }
.pctc .block-head p { color: var(--ink-2); max-width: 60ch }

.pctc .tools { display: grid; grid-template-columns: repeat(auto-fit,minmax(258px,1fr)); gap: 16px }
.pctc .tool { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; transition: border-color .2s, box-shadow .2s, transform .2s }
.pctc .tool:hover { border-color: var(--line-2); box-shadow: var(--shadow); transform: translateY(-2px) }
.pctc .tool h3 { font-size: 16.5px; display: flex; align-items: center; gap: 9px; margin-bottom: 4px }
.pctc .tool h3 .tick { width: 7px; height: 7px; border-radius: 2px; background: var(--brand); flex: none }
.pctc .tool .sub { font-size: 13px; color: var(--ink-3); margin-bottom: 16px }
.pctc .rowin { display: flex; align-items: center; gap: 10px; margin-bottom: 9px }
.pctc .rowin label { font-size: 13.5px; color: var(--ink-2); flex: 1; min-width: 0 }
.pctc .rowin input, .pctc .rowin select { width: 104px; flex: none; text-align: right; font-family: var(--mono); font-size: 13.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; transition: border-color .18s, box-shadow .18s }
.pctc .rowin select { text-align: left; cursor: pointer }
.pctc .rowin input:focus, .pctc .rowin select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent) }
.pctc .rowin input::-webkit-outer-spin-button, .pctc .rowin input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0 }
.pctc .tool-out { margin-top: auto; padding-top: 15px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 7px }
.pctc .oline { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 13.5px }
.pctc .oline span { color: var(--ink-3) }
.pctc .oline b { font-family: var(--mono); font-weight: 500; color: var(--ink); font-size: 14px }
.pctc .oline.hero-out b { font-family: var(--display); font-size: 23px; font-weight: 700; letter-spacing: -.03em; color: var(--brand) }
.pctc .oline.hero-out.neg b { color: var(--neg) }

/* ---------------- converter ---------------- */
.pctc .conv { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden }
.pctc .conv-top { padding: 20px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; flex-wrap: wrap }
.pctc .conv-top label { font-size: 14px; color: var(--ink-2) }
.pctc .conv-top input { width: 150px; font-family: var(--mono); font-size: 18px; font-weight: 500; text-align: right; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px }
.pctc .conv-top input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent) }
.pctc .conv-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)) }
.pctc .cv { padding: 18px 22px; border-right: 1px solid var(--line); border-top: 1px solid transparent }
.pctc .cv:last-child { border-right: 0 }
.pctc .cv .k { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3) }
.pctc .cv .v { font-family: var(--display); font-size: 24px; font-weight: 600; letter-spacing: -.03em; margin-top: 5px; word-break: break-all }

/* ---------------- reference ---------------- */
.pctc .ref-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(270px,1fr)); gap: 16px }
.pctc .fcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 18px }
.pctc .fcard h4 { font-size: 14.5px; font-family: var(--body); font-weight: 600; margin-bottom: 9px }
.pctc .fcard .fx { font-family: var(--mono); font-size: 13px; color: var(--brand); background: var(--brand-soft); border-radius: 7px; padding: 9px 12px; display: block; overflow-x: auto; white-space: nowrap }
.pctc .fcard .ex { margin-top: 9px; font-size: 13px; color: var(--ink-2) }
.pctc table.common { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden }
.pctc table.common th, .pctc table.common td { padding: 11px 16px; text-align: left; font-size: 14px; border-bottom: 1px solid var(--line) }
.pctc table.common th { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; background: var(--surface-2) }
.pctc table.common td { font-family: var(--mono); font-size: 13.5px; color: var(--ink-2) }
.pctc table.common td:first-child { color: var(--ink); font-weight: 500 }
.pctc table.common tr:last-child td { border-bottom: 0 }
.pctc table.common tbody tr { transition: background .15s }
.pctc table.common tbody tr:hover { background: var(--surface-2) }

.pctc .faq { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 22px }
.pctc details { border-top: 1px solid var(--line) }
.pctc details:first-of-type { border-top: 0 }
.pctc summary { cursor: pointer; list-style: none; padding: 16px 0; font-weight: 600; font-size: 15.5px; display: flex; align-items: center; gap: 12px }
.pctc summary::-webkit-details-marker { display: none }
.pctc summary::before { content: ""; width: 9px; height: 9px; flex: none; border-right: 2px solid var(--brand); border-bottom: 2px solid var(--brand); transform: rotate(-45deg) translate(1px,-1px); transition: transform .25s }
.pctc details[open] summary::before { transform: rotate(45deg) translate(0,0) }
.pctc details .ans { padding: 0 0 18px 21px; color: var(--ink-2); font-size: 14.8px }
.pctc details .ans code { font-family: var(--mono); font-size: 12.8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px }

.pctc .toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%,20px); background: var(--ink); color: var(--paper); font-size: 13.5px; font-weight: 500; padding: 10px 18px; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 60 }
.pctc .toast.show { opacity: 1; transform: translate(-50%,0) }

/* quick percentage chips */
.pctc .quickrow { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 20px }
.pctc .quickrow .qlab { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-right: 2px }
.pctc .qchip { font-family: var(--mono); font-size: 12.5px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); transition: border-color .18s, color .18s, background .18s, transform .12s }
.pctc .qchip:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft) }
.pctc .qchip:active { transform: scale(.95) }
.pctc .qchip.on { background: var(--brand); border-color: var(--brand); color: #fff }
[data-theme="dark"] .pctc .qchip.on { color: #0B1614 }
.pctc .quickrow[hidden] { display: none }

/* recent calculations */
.pctc .recent { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line) }
.pctc .recent-lab { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3) }
.pctc .recent-list { display: flex; gap: 6px; flex-wrap: wrap }
.pctc .rchip { font-size: 12.5px; padding: 5px 11px; border-radius: 8px; border: 1px solid var(--line); color: var(--ink-2); background: var(--surface-2); max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: border-color .18s, color .18s }
.pctc .rchip:hover { border-color: var(--brand); color: var(--brand) }

.pctc .related { display: grid; grid-template-columns: repeat(auto-fit,minmax(230px,1fr)); gap: 14px }
.pctc .rel { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 17px 19px; text-decoration: none; transition: border-color .2s, transform .2s, box-shadow .2s }
.pctc .rel:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--shadow) }
.pctc .rel b { display: block; font-family: var(--display); font-size: 16px; font-weight: 600; color: var(--ink); letter-spacing: -.02em }
.pctc .rel span { display: block; margin-top: 4px; font-size: 13px; color: var(--ink-3) }

@media print { .pctc .quickrow, .pctc .recent, .pctc .toast, .pctc .tabrail .tab:not([aria-selected="true"]) { display: none !important } }
@media (prefers-reduced-motion: reduce) { .pctc * { animation-duration: .001ms !important; transition-duration: .001ms !important } }
