/* Shared foundation: tokens, fonts, reset, controls. Public site and admin both load this first.
   Identity: the CYSSA "blocks" -- two isometric plates, one teal, one graphite. Hard-edged shadows stand in for
   plate thickness; 30-degree cuts and an isometric lattice are the only ornament. */

@font-face {
  font-family: "Schibsted Grotesk";
  src: url("../fonts/schibsted-grotesk.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/source-serif-4.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Surfaces: cool paper, so the (very colourful) book covers carry the colour. */
  --paper: #f3f6f8;
  --sheet: #ffffff;
  --sunken: #e8eef2;

  /* Ink: four text levels, all AA on --paper. */
  --ink: #0c2230;
  --ink-2: #29404e;
  --ink-3: #415768;
  --ink-4: #566b7b;

  /* Brand: the logo blue, plus the teal and graphite of the two plates. */
  --brand: #17608a;
  --brand-deep: #0f4a6c;
  --brand-wash: #e3eff5;
  --brand-line: #b4d1e1;
  --teal: #37a3bd;
  --plate: #b4bfc6;       /* graphite plate: the hard shadow behind covers */
  --plate-deep: #8b9aa4;

  /* Rules are low-opacity ink so they blend into any surface. */
  --rule: rgba(12, 34, 48, 0.13);
  --rule-soft: rgba(12, 34, 48, 0.07);
  --rule-strong: rgba(12, 34, 48, 0.3);

  /* Deep: the brand taken dark, for the footer and the closing call to action. Aqua is the highlight on it. */
  --deep: #0b3a52;
  --deep-2: #072a3c;
  --deep-line: rgba(234, 243, 247, 0.18);
  --on-deep: #eaf3f7;
  --on-deep-soft: #a9c6d4;
  --aqua: #7fdcea;
  --aqua-deep: #a6e8f2;

  --ok: #1d6f46;
  --ok-wash: #e5f3ec;
  --warn: #8a5a00;
  --warn-wash: #fbf1dc;
  --bad: #a8261d;
  --bad-wash: #fbe9e7;

  --font-sans: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;

  /* 4px base spacing scale */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;
  --s9: 96px;

  --r-s: 3px;
  --r-m: 6px;
  --r-l: 10px;

  --hit: 44px;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --focus: 0 0 0 2px var(--sheet), 0 0 0 4px var(--brand);

  /* Isometric lattice (30deg rhombi), a faint texture behind heroes and page heads */
  --lattice: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='52' height='60' viewBox='0 0 52 60'%3E%3Cpath d='M26 0 52 15v30L26 60 0 45V15z M26 30 0 15 M26 30l26-15 M26 30v30' fill='none' stroke='%2317608a' stroke-opacity='.16' stroke-width='1'/%3E%3C/svg%3E");
}

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

html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Keep focused fields clear of the sticky save bar in the admin */
  scroll-padding-block: var(--s9);
}
a, button, summary, label, input, select, textarea { touch-action: manipulation; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.025em;
  text-wrap: balance;
}
p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { display: block; max-width: 100%; height: auto; }
a { color: var(--brand-deep); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:target { scroll-margin-top: var(--s7); }

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--r-s);
}

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

.skip-link {
  position: absolute;
  left: var(--s4);
  top: -100px;
  z-index: 100;
  padding: var(--s3) var(--s4);
  background: var(--ink);
  color: #fff;
  border-radius: var(--r-s);
}
.skip-link:focus { top: var(--s3); color: #fff; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--hit);
  padding: 0 var(--s5);
  border: 1px solid transparent;
  border-radius: var(--r-m);
  background: var(--brand);
  color: #fff;
  font-weight: 650;
  font-size: 0.9375rem;
  line-height: 1;
  letter-spacing: -0.005em;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), transform 140ms var(--ease);
}
/* Hover only where a pointer can hover, so touch screens never latch a "stuck" hover state after a tap. */
@media (hover: hover) {
  .btn:hover { background: var(--brand-deep); color: #fff; }
}
.btn:active:not(:disabled):not([aria-disabled="true"]) { transform: scale(0.96); }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--sunken); color: var(--ink-4); cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }

.btn--quiet {
  background: var(--sheet);
  color: var(--ink);
  border-color: var(--rule-strong);
}
@media (hover: hover) {
  .btn--quiet:hover { background: var(--sunken); color: var(--ink); border-color: var(--ink-4); }
}

.btn--danger { background: var(--bad); }
.btn--danger:hover { background: #8c1f17; }
.btn--small { min-height: 36px; padding: 0 var(--s4); font-size: 0.875rem; }

/* ---------- Form controls (inputs are inset: slightly darker than the surface they sit on) ---------- */
.field { display: grid; gap: var(--s2); }
.field > label, .field > .label { font-weight: 600; font-size: 0.875rem; color: var(--ink-2); }
.hint { font-size: 0.8125rem; color: var(--ink-3); }
.field-error { font-size: 0.8125rem; color: var(--bad); font-weight: 500; }

.input, .textarea, .select {
  width: 100%;
  min-height: var(--hit);
  padding: var(--s2) var(--s3);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-s);
  transition: border-color 140ms var(--ease), background-color 140ms var(--ease);
}
.textarea { min-height: 9rem; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--ink-4); }
.input:focus, .textarea:focus, .select:focus { background: var(--sheet); border-color: var(--brand); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--bad); background: var(--bad-wash); }

.alert {
  padding: var(--s3) var(--s4);
  border: 1px solid var(--rule);
  border-left-width: 3px;
  border-radius: var(--r-s);
  background: var(--sheet);
  font-size: 0.9375rem;
}
.alert--ok { border-left-color: var(--ok); background: var(--ok-wash); }
.alert--error { border-left-color: var(--bad); background: var(--bad-wash); }

/* ---------- Covers ---------- */
.cover {
  position: relative;
  display: block;
  aspect-ratio: 2 / 3;
  background: var(--sunken);
  border-radius: 2px;
  /* The hard shadow is the plate the book sits on: thickness, not blur. */
  box-shadow: 0 0 0 1px rgba(12, 34, 48, 0.12), 5px 5px 0 var(--plate);
  overflow: hidden;
  transition: transform 220ms var(--ease), box-shadow 220ms var(--ease);
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
/* A 1px inner edge so pale covers don't dissolve into the page */
.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(12, 34, 48, 0.1);
  pointer-events: none;
}
.cover--empty { display: grid; place-items: center; padding: var(--s4); background: var(--brand-wash); }
.cover__title { font-family: var(--font-serif); font-size: 1.125rem; line-height: 1.25; text-align: center; color: var(--brand-deep); }

/* ---------- Pager (public catalog and admin list) ---------- */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--s2); }
.pager ol { display: flex; flex-wrap: wrap; gap: var(--s1); }
.pager a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--hit);
  min-height: var(--hit);
  padding: 0 var(--s3);
  border-radius: var(--r-s);
  color: var(--ink-2);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}
.pager a:hover { background: var(--sunken); color: var(--ink); }
.pager a[aria-current="page"] { background: var(--brand); color: #fff; }
.pager__step { border: 1px solid var(--rule-strong); }

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