/* ── Umain Helvetica Now (self-hosted) ── */
@font-face {
  font-family: 'Helvetica Now';
  src: url('/fonts/helvetica-now-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Helvetica Now';
  src: url('/fonts/helvetica-now-medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Helvetica Now';
  src: url('/fonts/helvetica-now-bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Helvetica Now Micro';
  src: url('/fonts/helvetica-now-micro.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg:       #f0f0f0;
  --surface:  #ffffff;
  --ink:      #0a0a0a;
  --muted:    #646464;
  --subtle:   #a3a3a3;
  --rule:     #d6d6d6;
  --rule-hi:  #0a0a0a;
  --accent:   #faa21b;
  --danger:   #c6281f;
  --font:     'Helvetica Now', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-micro: 'Helvetica Now Micro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --shell:    640px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* Extra left padding compensates for vertical tab bars (Arc, Vivaldi,
     etc.) that sit on the left edge of the viewport and cover the left
     gutter. Non-Arc users see the content shifted slightly right of
     centre — acceptable trade-off for reliable sidebar visibility. */
  padding: 1.75rem 1.5rem 3rem 20rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, var(--shell)) minmax(0, 1fr);
  column-gap: 3rem;
  align-items: start;
}

.shell {
  grid-column: 2;
  width: 100%;
  max-width: var(--shell);
}

.brand-sidebar {
  grid-column: 1;
  justify-self: end;
  font-size: clamp(2.25rem, 5vw + 1rem, 3.25rem);
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.02;
  color: var(--ink);
  padding-right: 3rem;
  border-right: 1px solid var(--rule);
  display: flex;
  align-items: flex-start;
  gap: 0.35em;
}
.brand-logo {
  width: 3.4em;
  height: auto;   /* aspect ratio comes from the SVG viewBox (20:15) */
  flex-shrink: 0;
  overflow: visible;  /* let the dropping balls render above the viewBox */
}

/* Hide the decorative animation for users who opt out of motion. */
@media (prefers-reduced-motion: reduce) {
  .brand-logo .balls { display: none; }
}
.brand-sidebar span {
  /* Crop the text line-box so its top is at the cap-height of the font,
     not the (taller) font ascent. Lets the "D" cap-top sit at the same y
     as the logo's first row of squares under align-items: flex-start. */
  text-box: trim-start cap;
}

@media (max-width: 1280px) {
  body {
    grid-template-columns: 1fr;
    column-gap: 0;
    padding-left: 1.5rem;
  }
  .brand-sidebar {
    grid-column: 1;
    justify-self: start;
    padding-right: 0;
    border-right: 0;
    margin-bottom: 1.5rem;
  }
  .shell { grid-column: 1; margin: 0 auto; }
}

/* ── Top bar (Umain template header: 4 meta columns + square mark) ── */
.topbar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr auto;
  gap: 1rem;
  align-items: center;
  padding-bottom: 1rem;
  margin-bottom: 5rem;
  font-family: var(--font-micro);
  font-size: .78rem;
  font-weight: 400;
  color: var(--ink);
}
.topbar > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wordmark {
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: -.015em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark .reg {
  font-size: .55em;
  vertical-align: super;
  margin-left: .05em;
}
.topbar .muted { color: var(--muted); font-weight: 500; }
.topbar .mark {
  width: 10px; height: 10px;
  background: var(--ink);
  justify-self: end;
}

/* ── Hero ── */
.hero { margin-bottom: 4rem; }
.eyebrow {
  font-size: .78rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 1.25rem;
}
h1.title {
  font-size: clamp(2.25rem, 5vw + 1rem, 3.25rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -.03em;
  margin-bottom: 1.25rem;
}
.lede {
  font-size: 1rem;
  color: var(--muted);
  max-width: 52ch;
  line-height: 1.5;
}
.hero-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin-top: 1.25rem;
  font-size: .9rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 2px;
}
.hero-link .arrow { transition: transform .2s; }
.hero-link:hover .arrow { transform: translateX(4px); }

/* ── Back link ── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .85rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 2.25rem;
  transition: color .15s, gap .2s;
}
.back-link:hover { color: var(--ink); gap: .6rem; }

/* ── Section label ── */
.section-label {
  font-size: .82rem;
  font-weight: 500;
  color: var(--muted);
  padding-top: 1.25rem;
  margin-bottom: 1.25rem;
  border-top: 1px solid var(--rule);
}
.section-label b { color: var(--ink); font-weight: 700; margin-right: .35rem; }

/* ── Fact list (security page) ── */
.facts {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--rule);
  margin-bottom: 3rem;
}
.fact {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 1.5rem;
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--rule);
}
.fact:last-child { border-bottom: 0; }
.fact-num {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
  line-height: 1;
  padding-top: .1rem;
}
.fact-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -.015em;
  margin-bottom: .5rem;
  color: var(--ink);
}
.fact-body {
  font-size: .95rem;
  color: var(--muted);
  line-height: 1.55;
}
.fact-body p + p { margin-top: .65rem; }
.fact-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .86em;
  color: var(--ink);
  background: #e4e4e4;
  padding: 0 .3em;
}
.fact-list { list-style: none; margin-top: .25rem; }
.fact-list li {
  padding-left: 1.1rem;
  position: relative;
  margin-bottom: .35rem;
  color: var(--muted);
  font-size: .95rem;
}
.fact-list li::before {
  content: '';
  position: absolute;
  left: 0; top: .65em;
  width: 8px; height: 1px;
  background: var(--ink);
}

/* ── Type selector ── */
.type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
  margin-bottom: 4rem;
}
.type-btn {
  background: transparent;
  border: 0;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 1.4rem 1.4rem;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  color: var(--ink);
  font-family: var(--font);
}
.type-btn:hover { background: #e8e8e8; }
.type-btn.active { background: var(--ink); color: #fff; }
.type-btn .icon {
  flex-shrink: 0;
  color: currentColor;
  margin-top: .1rem;
}
.type-btn .icon svg { width: 22px; height: 22px; display: block; }
.type-btn .label { font-size: .95rem; font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }
.type-btn .sublabel { font-size: .78rem; color: var(--muted); line-height: 1.35; margin-top: .3rem; font-weight: 500; }
.type-btn.active .sublabel { color: rgba(255,255,255,.65); }

/* ── Fields ── */
.fields { display: flex; flex-direction: column; gap: 1.5rem; }
.field-group { display: flex; flex-direction: column; gap: .5rem; }
.field-group label {
  font-size: .82rem;
  font-weight: 500;
  color: var(--muted);
}
.field-group input,
.field-group textarea {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 500;
  padding: .6rem 0;
  width: 100%;
  transition: border-color .15s;
  outline: none;
}
.field-group input::placeholder,
.field-group textarea::placeholder { color: var(--subtle); font-weight: 400; }
.field-group input:focus,
.field-group textarea:focus { border-bottom-color: var(--ink); }
.field-group textarea { resize: vertical; min-height: 140px; line-height: 1.5; }

/* ── Submit ── */
.submit-btn {
  margin-top: 2.5rem;
  width: 100%;
  background: var(--ink);
  color: #fff;
  border: 0;
  font-family: var(--font);
  font-size: .95rem;
  font-weight: 700;
  padding: 1.1rem 1.3rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  transition: background .15s, color .15s;
}
.submit-btn:hover { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.submit-btn:disabled { opacity: .4; cursor: not-allowed; background: var(--ink); color: #fff; box-shadow: none; }
.submit-btn .arrow { font-size: 1.2rem; line-height: 1; transition: transform .2s; }
.submit-btn:hover .arrow { transform: translateX(5px); }

/* ── Result banner ── */
.result {
  display: none;
  margin-top: 2rem;
  padding: 1.25rem 1.3rem;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  background: #fafafa;
}
.result.show { display: block; }
.result-label {
  font-size: .8rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: .3rem;
}
.result-body {
  font-size: .95rem;
  color: var(--muted);
  margin-bottom: 1rem;
  max-width: 52ch;
}
.result-url {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--rule);
  background: #fff;
}
.result-url code {
  flex: 1;
  min-width: 0;
  padding: .65rem .8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .8rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  user-select: all;
}
.copy-btn {
  flex-shrink: 0;
  border: 0;
  border-left: 1px solid var(--rule);
  background: #fff;
  color: var(--ink);
  font-family: var(--font);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 0 1rem;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.copy-btn:hover { background: var(--ink); color: #fff; }
.copy-btn.copied { background: var(--accent); color: var(--ink); border-left-color: var(--accent); }

/* ── Footer ── */
.footer {
  margin-top: 5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-micro);
  font-size: .75rem;
  color: var(--muted);
}
.footer .pagenum { color: var(--subtle); }
.footer a { color: var(--ink); text-decoration: none; border-bottom: 1px solid transparent; }
.footer a:hover { border-bottom-color: var(--ink); }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 1.5rem; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: #fff;
  padding: .85rem 1.1rem;
  font-size: .85rem;
  font-weight: 500;
  display: flex; align-items: center; gap: .6rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 999;
  max-width: calc(100vw - 3rem);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.success::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--accent);
  flex-shrink: 0;
}
#toast.error { background: var(--danger); }
