/* The Password Notebook: an exercise-book page.
   Cool paper on a darker desk, blue rules, one red margin line, blue-black ink. */

@font-face {
  font-family: "Literata";
  font-style: normal;
  font-display: swap;
  font-weight: 400 640; /* subset: Latin-1 + Latin Extended-A (covers Croatian), wght 400-640, full opsz */
  src: url("/fonts/literata-normal-subset.woff2") format("woff2-variations");
}
@font-face {
  font-family: "Literata";
  font-style: italic;
  font-display: swap;
  font-weight: 400 500; /* static instance at 420, Latin-1 + Latin Extended-A: italic is only used for short labels */
  src: url("/fonts/literata-italic-subset.woff2") format("woff2");
}
@font-face {
  font-family: "Kalam";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url("/fonts/kalam-latin-400-normal.woff2") format("woff2");
}

:root {
  --paper: #f5f7f8;
  --paper-deep: #e4eaf0;
  --ink: #1d2b47;
  --ink-soft: #4d5b74;
  --pen: #1a3a8a;
  --rule: #b9cde3;
  --rule-faint: #dbe6f1;
  --margin: #c8423a;
  --cloth: #22304f;
  --cloth-text: #c9d3e6;
  --focus: #1f6feb;

  --serif: "Literata", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --hand: "Kalam", "Bradley Hand", "Segoe Print", cursive;

  /* Type scale: ratio 1.25 on a 1.1875rem (19px) body, set generously for older readers. */
  --step--1: 0.95rem;
  --step-0: 1.1875rem;
  --step-1: 1.48rem;
  --step-2: 1.85rem;
  --step-3: 2.32rem;
  --step-4: clamp(2.2rem, 1.5rem + 3vw, 3.4rem);

  --line: 2rem;          /* the ruled-line pitch */
  --measure: 40rem;      /* reading column */
  --sheet: 64rem;        /* width of the paper on wide screens */
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --margin-x: clamp(2.5rem, 7vw, 5.5rem); /* where the red margin line sits */
  --baseline: 0.44;      /* Literata (ascent - descent) / 2, in em: baseline position inside a line box */
}
@media (max-width: 480px) {
  :root { --margin-x: 1.5rem; --gutter: 1rem; }
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
/* Sections start with 2.5 lines of padding, which clears the sticky tab strip on tablets.
   On phones the strip is not sticky (see below), so no offset is needed. */
.doc h2[id] { scroll-margin-top: 1.5rem; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

body {
  margin: 0;
  background: var(--paper-deep);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--step-0);
  line-height: 1.65;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
}

/* One sheet of paper; the red margin line runs its full height. */
.page {
  position: relative;
  min-height: 100vh;
  max-width: var(--sheet);
  margin: 0 auto;
  background: var(--paper);
  box-shadow: 0 0 0 1px var(--rule), 0 30px 60px -40px rgba(29, 43, 71, 0.35);
}
.page::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 var(--margin-x);
  width: 2px;
  background: var(--margin);
  opacity: 0.75;
  pointer-events: none;
  z-index: 1;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0.75rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip:focus { left: 0.75rem; }

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

a {
  color: var(--ink);
  text-decoration-color: var(--ink-soft);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}
a:hover { text-decoration-color: var(--ink); text-decoration-thickness: 3px; }

.column {
  max-width: calc(var(--measure) + var(--margin-x) + var(--gutter) * 2);
  padding-left: calc(var(--margin-x) + var(--gutter));
  padding-right: var(--gutter);
}

p, ul, ol, dl, table { margin: 0 0 1.1em; }
ul, ol { padding-left: 1.2em; }
li + li { margin-top: 0.45em; }
strong { font-weight: 640; }

h1, h2, h3 {
  font-weight: 560;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0;
  text-wrap: balance;
}
h2 { font-size: var(--step-3); margin-bottom: 0.6em; }
h3 { font-size: var(--step-1); margin-bottom: 0.35em; }
p, li { text-wrap: pretty; }

.lede { font-size: var(--step-1); line-height: 1.5; color: var(--ink-soft); }
.small { font-size: var(--step--1); color: var(--ink-soft); }

/* ---------- Masthead ---------- */
.masthead {
  max-width: none;
  padding-top: 1.75rem;
  padding-bottom: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
}
.wordmark {
  font-size: var(--step-0);
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  padding: 0.4rem 0;
}
.wordmark span { font-style: italic; font-weight: 420; }
.checked { font-size: var(--step--1); color: var(--ink-soft); margin: 0; }

/* ---------- Hero: headline and lede sit on the ruled lines ---------- */
.hero {
  padding-top: calc(var(--line) * 2);
  padding-bottom: calc(var(--line) * 2);
}
.hero h1 {
  font-size: var(--step-4);
  font-weight: 600;
  line-height: calc(var(--line) * 1.5);
  letter-spacing: -0.02em;
  max-width: 18ch;
  margin-bottom: calc(var(--line) * 0.5);
}
.hero .lede { max-width: 36ch; margin-bottom: var(--line); }

@media (min-width: 561px) {
  .hero {
    background-image: repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(var(--line) - 1px),
      var(--rule-faint) calc(var(--line) - 1px),
      var(--rule-faint) var(--line)
    );
    /* A rule ~4px under each lede baseline. */
    background-position: 0 calc(var(--line) / 2 + var(--baseline) * var(--step-1) + 4px - var(--line) + 1px);
  }
  .hero h1 {
    line-height: calc(var(--line) * 2);
    margin-bottom: var(--line);
    position: relative;
    /* Move the headline's baselines onto the same rules (visual nudge only). */
    top: calc(var(--baseline) * var(--step-1) - var(--baseline) * var(--step-4) - var(--line) / 2);
  }
  .hero .lede { line-height: var(--line); }
}

/* A filled-in logbook entry: the page's signature element. */
.entry {
  max-width: 34rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-left: 6px solid var(--cloth);
  padding: 1.25rem 1.5rem 0.75rem;
  margin: 0 0 1.25rem;
  box-shadow: 0 1px 0 var(--rule), 0 14px 30px -22px rgba(29, 43, 71, 0.45);
  position: relative;
  z-index: 2;
}
.entry-title {
  font-size: var(--step--1);
  color: var(--ink-soft);
  margin: 0 0 0.6rem;
  font-style: italic;
}
.entry dl { display: grid; grid-template-columns: max-content 1fr; column-gap: 1rem; margin: 0; }
.entry dt {
  font-size: var(--step--1);
  color: var(--ink-soft);
  padding-top: 0.55rem;
}
.entry dd {
  margin: 0;
  font-family: var(--hand);
  font-size: 1.35rem;
  line-height: 1.2;
  color: var(--pen);
  border-bottom: 1px solid var(--rule);
  padding: 0.4rem 0 0.2rem;
  min-height: 2.25rem;
}
.entry dd .strike { text-decoration: line-through; text-decoration-color: var(--margin); text-decoration-thickness: 2px; margin-right: 0.6rem; }
@media (min-width: 481px) { .entry dd .hint { white-space: nowrap; } }
.entry-note {
  font-size: var(--step--1);
  color: var(--ink-soft);
  margin: 0.75rem 0 0;
}
@media (max-width: 480px) {
  .entry { padding-left: 1rem; padding-right: 1rem; }
  .entry dl { grid-template-columns: 1fr; }
  .entry dt { padding-top: 0.5rem; }
  .entry dd .strike { display: block; margin-right: 0; }
}

/* ---------- Thumb index (section tabs cut into the page edge) ---------- */
.thumb-index {
  --tab-w: 8.75rem;
  position: fixed;
  /* Tabs overlap the paper's right edge by 0.5rem, so they look cut into the sheet. */
  right: max(0px, calc((100vw - var(--sheet)) / 2 - var(--tab-w) + 0.5rem));
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
}
.thumb-index ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.thumb-index li + li { margin-top: 0; }
.thumb-index li:nth-child(1) { --tab-bg: #dfe8f2; }
.thumb-index li:nth-child(2) { --tab-bg: #d3e0ec; }
.thumb-index li:nth-child(3) { --tab-bg: #c8d8e7; }
.thumb-index li:nth-child(4) { --tab-bg: #bdd0e2; }
.thumb-index li:nth-child(5) { --tab-bg: #b2c8dd; }
.thumb-index a {
  display: block;
  width: var(--tab-w);
  padding: 0.6rem 0.9rem 0.6rem 0.8rem;
  font-size: var(--step--1);
  line-height: 1.2;
  text-decoration: none;
  color: var(--ink);
  background: var(--tab-bg);
  border-radius: 6px 0 0 6px;
  border: 1px solid var(--rule);
  border-right: 0;
  transition: transform 180ms ease, background-color 180ms ease, color 180ms ease;
}
.thumb-index a:hover,
.thumb-index a:focus-visible,
.thumb-index a[aria-current="true"] { transform: translateX(-0.75rem); }
.thumb-index a[aria-current="true"] { background: var(--cloth); color: #fff; border-color: var(--cloth); }
.thumb-index a:focus-visible { outline-color: var(--ink); outline-offset: -4px; }
.thumb-index a[aria-current="true"]:focus-visible { outline-color: #fff; }

/* Tablets and small laptops: a sticky row of tabs along the top edge. */
@media (max-width: 1100px) {
  .thumb-index {
    position: sticky;
    top: 0;
    right: auto;
    transform: none;
    border-bottom: 1px solid var(--rule);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    /* Keep the red margin line continuous through the bar. */
    background:
      linear-gradient(to right,
        transparent var(--margin-x),
        rgba(200, 66, 58, 0.75) var(--margin-x),
        rgba(200, 66, 58, 0.75) calc(var(--margin-x) + 2px),
        transparent calc(var(--margin-x) + 2px)) no-repeat,
      var(--paper);
  }
  .thumb-index.has-more {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent);
  }
  .thumb-index ol {
    flex-direction: row;
    align-items: flex-end;
    padding: 0.4rem var(--gutter) 0 calc(var(--margin-x) + var(--gutter));
    gap: 6px;
  }
  .thumb-index a {
    transform: none;
    display: flex;
    align-items: center;
    min-height: 44px;
    width: auto;
    padding: 0 0.9rem;
    margin-top: 0.35rem;
    white-space: nowrap;
    border-radius: 6px 6px 0 0;
    border: 1px solid var(--rule);
    border-bottom: 0;
    transition: margin-top 180ms ease, background-color 180ms ease, color 180ms ease;
  }
  .thumb-index a:hover,
  .thumb-index a:focus-visible,
  .thumb-index a[aria-current="true"] { transform: none; margin-top: 0; }
  /* Links from the at-a-glance table land below the sticky strip. */
  .pick[id] { scroll-margin-top: 3.5rem; }
}

/* Phones: every tab visible, wrapping onto two rows. */
@media (max-width: 620px) {
  /* Not sticky: wrapped tabs would cover a quarter of a small screen. */
  .thumb-index { position: static; overflow-x: visible; }
  .pick[id] { scroll-margin-top: 0; }
  .thumb-index.has-more { -webkit-mask-image: none; mask-image: none; }
  .thumb-index ol {
    flex-wrap: wrap;
    align-items: stretch;
    padding: 0.5rem var(--gutter) 0.5rem calc(var(--margin-x) + var(--gutter));
    gap: 6px;
  }
  .thumb-index a {
    margin-top: 0;
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 0 0.75rem;
  }
}

/* ---------- Sections ---------- */
section { padding-top: calc(var(--line) * 2.5); padding-bottom: var(--line); }
section > .column > p,
section > .column > ul,
section > .column > ol { max-width: var(--measure); }

/* Picks: each product is a logbook row, not a card. */
.picks { list-style: none; padding: 0; margin: 1.5rem 0 0; border-top: 2px solid var(--ink); }
.picks > li { margin: 0; padding: 1.75rem 0 1.5rem; border-bottom: 1px solid var(--rule); }
/* A subsection that follows the list of picks (for example the seniors guide) needs its own breathing room. */
.picks + h3 { margin-top: 2.25rem; }
.pick-for {
  font-family: var(--hand);
  font-size: 1.3rem;
  color: var(--pen);
  line-height: 1.2;
  margin: 0 0 0.2rem;
}
.pick h3 { font-size: var(--step-1); }
.pick-brand { font-size: var(--step--1); color: var(--ink-soft); margin: 0 0 0.9rem; }
.pick-fields {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  column-gap: 1rem;
  row-gap: 0.15rem;
  margin: 0 0 1.1rem;
  max-width: var(--measure);
}
.pick-fields dt { font-size: var(--step--1); color: var(--ink-soft); padding-top: 0.2rem; }
.pick-fields dd { margin: 0 0 0.5rem; }
/* The size line is written in, like a logbook field. */
.pick-fields dd.size {
  font-family: var(--hand);
  font-size: 1.3rem;
  line-height: 1.3;
  color: var(--pen);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.15rem;
  margin-bottom: 0.75rem;
}
@media (max-width: 560px) {
  .pick-fields { grid-template-columns: 1fr; }
  .pick-fields dt { padding-top: 0.4rem; }
}

.buy {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--cloth);
  color: #fff;
  text-decoration: none;
  font-weight: 560;
  font-size: var(--step-0);
  padding: 0.7rem 1.2rem;
  border-radius: 4px;
  min-height: 48px;
}
.buy:hover { background: #2d3f68; color: #fff; }
.buy svg { width: 1em; height: 1em; flex: none; }
.buy-note { display: block; font-size: var(--step--1); color: var(--ink-soft); margin-top: 0.5rem; }

/* Rules for safe use: an unordered list with ink checkmarks. */
.rules { list-style: none; padding: 0; max-width: var(--measure); }
.rules li { position: relative; padding-left: 2.2rem; margin-top: 1.1rem; }
.rules li::before {
  content: "";
  position: absolute;
  left: 0.2rem;
  top: 0.5rem;
  width: 1.05rem;
  height: 0.55rem;
  border-left: 3px solid var(--pen);
  border-bottom: 3px solid var(--pen);
  transform: rotate(-45deg);
}
.rules strong { display: block; }

/* Paper vs password manager */
.compare-wrap { overflow-x: auto; max-width: calc(var(--measure) + 6rem + 12px); padding: 0 6px; margin: 0 -6px 1.1em; } /* 6px leaves room for focus rings inside the scroll box */
.compare { border-collapse: collapse; width: 100%; font-size: var(--step--1); line-height: 1.5; }
.compare caption { text-align: left; font-size: var(--step--1); color: var(--ink-soft); padding-bottom: 0.6rem; }
.compare th, .compare td { text-align: left; vertical-align: top; padding: 0.7rem 0.9rem 0.7rem 0; border-bottom: 1px solid var(--rule); }
.compare thead th { border-bottom: 2px solid var(--ink); font-size: var(--step-0); font-weight: 600; }
.compare tbody th { font-weight: 560; width: 28%; }
.compare .m-label { display: none; }
.glance tbody th { width: 34%; }
.glance td:nth-child(2) { white-space: nowrap; }
@media (max-width: 560px) {
  .compare-wrap { overflow-x: visible; }
  .compare, .compare tbody, .compare tr, .compare th, .compare td { display: block; width: auto; }
  .compare thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .compare tr { padding: 0.9rem 0; border-bottom: 1px solid var(--rule); }
  .compare tbody tr:first-child { border-top: 2px solid var(--ink); }
  .compare caption { display: block; }
  .compare tbody th[scope="row"] { width: auto; font-size: var(--step-0); font-weight: 600; padding: 0 0 0.3rem; border: 0; }
  .compare td { padding: 0.35rem 0 0.35rem 0.9rem; border: 0; border-left: 3px solid var(--rule-faint); margin-top: 0.4rem; font-size: var(--step-0); }
  .compare .m-label { display: block; font-size: var(--step--1); color: var(--ink-soft); font-weight: 600; }
  /* At-a-glance table: a compact 2 x 2 grid per pick instead of one long column. */
  .glance tr { display: grid; grid-template-columns: 1fr 1fr; column-gap: 1rem; row-gap: 0.15rem; }
  .glance tbody th[scope="row"] { grid-column: 1 / -1; }
  .glance td { margin-top: 0.25rem; padding: 0.1rem 0 0.1rem 0.6rem; font-size: var(--step--1); }
}

.aside {
  max-width: var(--measure);
  border-left: 3px solid var(--rule);
  padding: 0.25rem 0 0.25rem 1.1rem;
  color: var(--ink-soft);
}

/* FAQ */
.faq { max-width: var(--measure); border-top: 2px solid var(--ink); }
.faq details { border-bottom: 1px solid var(--rule); }
.faq summary {
  cursor: pointer;
  list-style: none;
  padding: 1.05rem 2.5rem 1.05rem 0;
  font-weight: 560;
  position: relative;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  position: absolute;
  right: 0.4rem;
  top: 0.85rem;
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--ink-soft);
  transition: transform 160ms ease;
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details > div { padding: 0 0 1rem; }

/* ---------- Footer: the notebook's back cover ---------- */
.cover {
  margin-top: calc(var(--line) * 2);
  background: var(--cloth);
  color: var(--cloth-text);
  padding: 2.5rem 0 3rem;
  position: relative;
  z-index: 2;
  font-size: var(--step--1);
}
.cover a, .cover .linklike { color: #fff; text-decoration-color: rgba(255, 255, 255, 0.55); }
.cover a:hover, .cover .linklike:hover { text-decoration-color: #fff; }
.cover :focus-visible { outline-color: #fff; }
.cover p { max-width: var(--measure); }
.cover .stamp { font-size: var(--step-0); font-weight: 600; color: #fff; margin-bottom: 0.9rem; }
.cover .stamp span { font-style: italic; font-weight: 420; }
.cover-links { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }
.cover-links li + li { margin-top: 0; }

/* Secondary pages (about, contact and privacy) */
.doc { padding-top: calc(var(--line) * 1.5); }
.doc h1 { font-size: var(--step-3); margin-bottom: 0.6em; }
.doc h2 { font-size: var(--step-1); margin: 1.6em 0 0.4em; }
.doc p, .doc ul { max-width: var(--measure); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1.25rem; max-width: var(--measure); }
.facts dt { color: var(--ink-soft); font-size: var(--step--1); padding-top: 0.15rem; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .facts { grid-template-columns: 1fr; } .facts dd { margin-bottom: 0.5rem; } }

/* ---------- Cookie consent (only present when analytics is configured) ---------- */
.consent {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 0 var(--gutter) max(1rem, env(safe-area-inset-bottom));
  pointer-events: none;
}
.consent[hidden] { display: none; }
.consent-inner {
  pointer-events: auto;
  max-width: 40rem;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--rule);
  border-left: 6px solid var(--cloth);
  box-shadow: 0 18px 40px -20px rgba(29, 43, 71, 0.55);
  padding: 1rem 1.25rem;
  font-size: var(--step--1);
  line-height: 1.5;
  /* Never taller than the screen: on short screens the banner scrolls instead of cutting off its text. */
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.consent-status { font-weight: 600; }
.consent-status[hidden] { display: none; }
@media (max-height: 420px) {
  .consent-inner { padding: 0.6rem 0.9rem; }
  .consent-inner p { margin-bottom: 0.5rem; }
  .consent-actions button { min-height: 40px; font-size: var(--step--1); }
}
/* While the banner is open, keep the end of the page (footer links) and focused elements clear of it. */
html:has(#consent:not([hidden])) { scroll-padding-bottom: var(--consent-h, 0px); }
body:has(#consent:not([hidden])) .page { padding-bottom: var(--consent-h, 0px); }
.consent-inner p { margin: 0 0 0.85rem; }
.consent-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
/* Both choices look the same: refusing is as easy as accepting. */
.consent-actions button {
  flex: 1 1 7rem;
  min-height: 44px;
  font: inherit;
  font-weight: 600;
  font-size: var(--step-0);
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--cloth);
  border-radius: 4px;
  cursor: pointer;
}
.consent-actions button:hover { background: var(--paper-deep); }
.linklike {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.55);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.linklike:hover { text-decoration-color: #fff; }
.linklike[hidden] { display: none; }

@media print {
  .thumb-index, .skip, .buy svg, .consent { display: none; }
  .page::before { display: none; }
  body, .page { background: #fff; }
  .page { max-width: none; box-shadow: none; }
  .hero { background: none; }
  .hero h1 { top: 0; }
  .entry { box-shadow: none; }
  .faq details::details-content { content-visibility: visible; display: block; }
  .faq summary::after { display: none; }
  #sources a::after { content: " (" attr(href) ")"; font-size: 0.85em; word-break: break-all; color: var(--ink-soft); }
  .cover { background: none; color: var(--ink); border-top: 1px solid var(--ink); }
  .cover a, .cover .linklike, .cover .stamp { color: var(--ink); }
  .buy { background: none; color: var(--ink); border: 1px solid var(--ink); }
}
