/* authorkit.pro — shared styles for web tools.
 *
 * Matches the main site's literary, book-craft identity:
 * Playfair Display + Source Serif 4, warm paper ground,
 * monochrome palette, ruled sections, no border-radius cards.
 *
 * All colours use CSS custom properties so dark mode works.
 */

:root {
  --black:   #000000;
  --white:   #ffffff;
  --stone:   #4a4845;
  --rule:    #000000;
  --rule-lt: rgba(0,0,0,.12);
  --paper:   #F8F6F1;
  --code-bg: #EFEDE8;

  --font-head: 'Playfair Display', Georgia, serif;
  --font-body: 'Source Serif 4', Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  --measure: 38rem;
  --pad: clamp(1rem, 4vw, 2rem);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --black:   #f0ece4;
    --white:   #13120d;
    --stone:   #9c968a;
    --rule:    rgba(240,236,228,.25);
    --rule-lt: rgba(240,236,228,.10);
    --paper:   #13120d;
    --code-bg: #1c1a14;
  }
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  background: var(--paper);
  color: var(--black);
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--black);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
a:hover { text-decoration-thickness: 2px; }

/* ── Layout ─────────────────────────────────────────────── */
.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding-left: var(--pad);
  padding-right: var(--pad);
}

/* Wider wrap for calculator pages — forms need more room */
.wrap--wide { max-width: 48rem; }

/* ── Masthead ───────────────────────────────────────────── */
.masthead {
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 20;
}

.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4.2rem;
}

.masthead__brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  text-decoration: none;
  color: var(--black);
}

.masthead__mark {
  width: 30px;
  height: 35px;
  flex-shrink: 0;
  fill: var(--black);
}

.masthead__name {
  font-family: var(--font-head);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1;
}

.masthead__nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-family: var(--font-body);
  font-size: .95rem;
}

.masthead__nav a {
  color: var(--stone);
  text-decoration: none;
  /* Icon-only: flex removes the inline-image baseline gap, and the padding
     keeps the tap target near 44px without enlarging the mark. */
  display: flex;
  align-items: center;
  padding: .35rem;
  margin: -.35rem;
  border-radius: 4px;
}
.masthead__nav a:hover { color: var(--black); }
.masthead__nav a[aria-current="page"] {
  color: var(--black);
  font-weight: 600;
}
.masthead__nav a:focus-visible {
  outline: 2px solid var(--black);
  outline-offset: 2px;
}

/* ── Hero / page heading ────────────────────────────────── */
.hero {
  padding-top: clamp(2.2rem, 5vw, 3.6rem);
  padding-bottom: 1.1rem;
}

.hero h1 {
  font-family: var(--font-head);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.02em;
  color: var(--black);
  margin-bottom: .75rem;
  text-wrap: balance;
}

.hero p {
  font-size: 1rem;
  color: var(--stone);
  text-wrap: pretty;
}

/* ── Section heads (uppercase label + rule) ──────────────── */
.section-head {
  font-family: var(--font-body);
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--stone);
  border-bottom: 1px solid var(--rule);
  padding-bottom: .45rem;
  margin-top: 2.2rem;
  margin-bottom: .9rem;
}

/* ── Forms ───────────────────────────────────────────────── */
.ak-field {
  margin-bottom: 1.1rem;
}

.ak-field label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--stone);
  margin-bottom: .35rem;
}

.ak-field select,
.ak-field input[type="number"],
.ak-field input[type="text"] {
  width: 100%;
  padding: .5rem .65rem;
  font-size: .95rem;
  font-family: var(--font-body);
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--black);
}

.ak-field select:focus,
.ak-field input:focus {
  outline: 2px solid var(--black);
  outline-offset: 1px;
}

.ak-hint {
  display: block;
  font-size: .75rem;
  color: var(--stone);
  margin-top: .25rem;
}

.ak-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.ak-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 600px) {
  .ak-grid-2, .ak-grid-3 { grid-template-columns: 1fr; }
  .masthead__nav { gap: 1rem; font-size: .85rem; white-space: nowrap; }
  .masthead__nav .masthead__gh { display: none; }
  .colophon__inner { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 380px) {
  .masthead__brand { gap: .5rem; }
  .masthead__name { font-size: 1.15rem; }
}

/* ── Results table ──────────────────────────────────────── */
.ak-results {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
  margin-bottom: 1.25rem;
}

.ak-results th,
.ak-results td {
  text-align: left;
  padding: .55rem .5rem .55rem 0;
  border-bottom: 1px solid var(--rule-lt);
  vertical-align: baseline;
}

.ak-results th {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: .9rem;
  color: var(--stone);
}
.ak-results thead th {
  border-bottom-color: var(--rule);
  padding-bottom: .4rem;
}
.ak-results th[scope="row"] { width: 40%; padding-right: 1rem; }

.ak-val {
  font-family: var(--font-mono);
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
}

.ak-highlight th,
.ak-highlight td {
  border-top: 1px solid var(--rule);
  border-bottom-color: var(--rule);
  padding-top: .7rem;
  padding-bottom: .7rem;
}

.ak-muted td { color: var(--stone); }

/* ── Ruled sections (instead of rounded cards) ───────────── */
.ak-section {
  border-top: 1px solid var(--rule);
  padding-top: 1.5rem;
  margin-top: 2.5rem;
}

.ak-section h2 {
  font-family: var(--font-head);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--black);
  margin-bottom: .9rem;
}

.ak-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.75rem;
  margin-bottom: .6rem;
}

/* ── Callout boxes ──────────────────────────────────────── */
.ak-callout {
  border: 1px solid var(--rule);
  padding: .9rem 1.1rem;
  font-size: .95rem;
  line-height: 1.6;
  margin: 1.25rem 0;
}

.ak-callout strong {
  display: block;
  margin-bottom: .2rem;
}

/* Subtle left-accent variants */
.ak-callout-info  { border-left-width: 3px; }
.ak-callout-warn  { border-left-width: 3px; }
.ak-callout-ok    { border-left-width: 3px; }

/* ── Prose (guide pages) ────────────────────────────────── */
.ak-prose h2 {
  font-family: var(--font-head);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--black);
  border-bottom: 1px solid var(--rule);
  padding-bottom: .45rem;
  margin-top: 2.2rem;
  margin-bottom: .9rem;
}

.ak-prose h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: .5rem;
}

.ak-prose p  { margin-bottom: .85rem; }
.ak-prose ul, .ak-prose ol {
  margin-bottom: .85rem;
  padding-left: 1.1rem;
  color: var(--stone);
}
.ak-prose li { margin: .3rem 0; }
.ak-prose a  { color: var(--black); }
.ak-prose code {
  font-family: var(--font-mono);
  font-size: .85em;
  background: var(--code-bg);
  padding: .1em .3em;
}

/* Numbered steps */
.ak-steps { counter-reset: step; list-style: none; padding-left: 0; }
.ak-steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 2.2rem;
  margin-bottom: 1.1rem;
  color: var(--stone);
}
.ak-steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: .15em;
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid var(--rule);
  font-family: var(--font-body);
  font-size: .75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--black);
}
.ak-steps > li strong { color: var(--black); }

/* ── Sources / citations ────────────────────────────────── */
.ak-sources {
  font-size: .8rem;
  color: var(--stone);
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule-lt);
}

.ak-sources ul { padding-left: 1.1rem; }
.ak-sources li { margin: .25rem 0; }
.ak-sources a {
  color: var(--stone);
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 2px;
}
.ak-sources a:hover {
  color: var(--black);
  text-decoration-color: var(--black);
}

/* ── Colophon / footer ──────────────────────────────────── */
.colophon {
  margin-top: auto;
  border-top: 1px solid var(--rule);
  padding: 1.25rem 0 2rem;
  font-size: .875rem;
  color: var(--stone);
}

.colophon__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
}

.colophon__brand {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.colophon__legal { white-space: nowrap; }

.colophon__mark {
  width: 13px;
  height: 15px;
  fill: var(--stone);
  flex-shrink: 0;
}

.colophon a { color: var(--stone); text-underline-offset: 2px; }
.colophon a:hover { color: var(--black); }

/* ── Resource page layout ────────────────────────────────
 * .wrap--page > .ak-crumbs, then .ak-page = main.ak-main + aside.ak-sidebar.
 * Wide: two columns, sidebar sticky. Narrow: one column, sidebar after main. */
.wrap--page { max-width: 64rem; width: 100%; } /* width: body is a flex column, so auto margins would shrink-wrap it */

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

.ak-skip { position: absolute; left: -999px; }
.ak-skip:focus { left: var(--pad); top: .5rem; z-index: 30; background: var(--paper); padding: .3rem .6rem; }

.ak-crumbs { font-size: .8rem; color: var(--stone); padding-top: 1rem; }
.ak-crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .1rem .4rem; }
.ak-crumbs li + li::before { content: "›"; margin-right: .4rem; }
.ak-crumbs a { color: var(--stone); }

.ak-page { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2.5rem; padding-bottom: 3rem; }
.ak-main .hero p, .ak-main .ak-prose { max-width: var(--measure); }

@media (min-width: 60rem) {
  .ak-page { grid-template-columns: minmax(0, 1fr) 16rem; }
  .ak-sidebar { position: sticky; top: 5.2rem; align-self: start; padding-top: clamp(2.2rem, 5vw, 3.6rem); }
}

.ak-sidebar { font-size: .85rem; }
.ak-sidebar h2 { font-family: var(--font-body); font-size: .85rem; font-weight: 600; border-bottom: 1px solid var(--rule); padding-bottom: .35rem; margin-bottom: .5rem; }
.ak-sidebar ul + h2 { margin-top: 1.5rem; }
.ak-sidebar ul { list-style: none; }
.ak-sidebar li { padding: .3rem 0; border-bottom: 1px solid var(--rule-lt); }
.ak-sidebar a { color: var(--stone); text-decoration: none; }
.ak-sidebar a:hover { color: var(--black); text-decoration: underline; }
.ak-sidebar a[aria-current="page"] { color: var(--black); font-weight: 600; }

/* The tool: a ruled box, inputs beside the visual when there is room. */
.ak-tool { border: 1px solid var(--rule); padding: clamp(.6rem, 3vw, 1.5rem); container-type: inline-size; }
.ak-tool__body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
@container (min-width: 34rem) {
  .ak-tool__body { grid-template-columns: minmax(0, 17rem) minmax(0, 1fr); align-items: start; }
}
.ak-tool .ak-results { margin: 1.5rem 0 0; }
.ak-tool .ak-field select { font-size: .85rem; }
@container (max-width: 20rem) { .ak-tool .ak-field select { font-size: .8rem; padding-left: .4rem; } }

.ak-field input[type="range"] { width: 100%; margin-top: .5rem; accent-color: var(--black); }

.ak-headline span { white-space: nowrap; }
.ak-headline { font-family: var(--font-mono); font-size: clamp(.85rem, 3.5vw, 1.05rem); font-variant-numeric: tabular-nums; margin-top: .6rem; }

/* To-scale diagrams: drawn in currentColor on --paper, so dark mode just works. */
.ak-proof { display: block; width: 100%; height: auto; color: var(--black); }
.ak-proof .line { fill: none; stroke: currentColor; stroke-width: 1; vector-effect: non-scaling-stroke; }
.ak-proof .fold { stroke-dasharray: 4 3; }
.ak-proof .faint { stroke: var(--stone); }
.ak-proof .paper { fill: var(--paper); }
.ak-proof text { fill: currentColor; font-family: var(--font-body); }
.ak-proof .small { fill: var(--stone); }

/* The section rule already separates; no second rule under the heading. */
.ak-section.ak-prose h2 { border-bottom: 0; padding-bottom: 0; margin-top: 0; }
.ak-prose .ak-steps { padding-left: 0; color: inherit; }

/* Draft pages: a calm notice that the content is not final. */
.ak-draft { border: 1px dashed var(--rule); padding: .7rem 1rem; font-size: .9rem; color: var(--stone); margin: 1rem 0; }
.ak-draft strong { color: var(--black); }

/* Hub list */
.ak-index { list-style: none; border-top: 1px solid var(--rule); margin-bottom: 3rem; }
.ak-index li { padding: .8rem 0; border-bottom: 1px solid var(--rule-lt); }
.ak-index a { font-weight: 600; }
.ak-index span { display: block; color: var(--stone); font-size: .9rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ── Utility ────────────────────────────────────────────── */
.ak-sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

/* Outbound links carry the brand's link arrow (same shape as Swati's
   Journal's .link-arrow): half opacity, nudges up-right on hover. */
main a[href^="http"]:not([href*="authorkit.pro"])::after,
.ak-sidebar a[href^="http"]:not([href*="authorkit.pro"])::after,
.colophon a[href^="http"]:not([href*="authorkit.pro"])::after {
  content: "";
  display: inline-block;
  width: .7em;
  height: .7em;
  margin-left: .2em;
  vertical-align: .02em;
  background: currentColor;
  opacity: .5;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='7' y1='17' x2='17' y2='7'/%3E%3Cpolyline points='7 7 17 7 17 17'/%3E%3C/svg%3E") no-repeat center / contain;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='7' y1='17' x2='17' y2='7'/%3E%3Cpolyline points='7 7 17 7 17 17'/%3E%3C/svg%3E") no-repeat center / contain;
  transition: transform .2s ease, opacity .2s ease;
}
main a[href^="http"]:not([href*="authorkit.pro"]):hover::after,
.ak-sidebar a[href^="http"]:not([href*="authorkit.pro"]):hover::after,
.colophon a[href^="http"]:not([href*="authorkit.pro"]):hover::after {
  transform: translate(2px, -2px);
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  main a::after, .ak-sidebar a::after, .colophon a::after { transition: none; }
}
