/* =====================================================================
   THE COIN ATLAS: shared styles (used by BOTH index.html and country.html)
   The look of a printed collector's catalogue: cream paper, ink-coloured
   text, magenta as the one accent colour, flat colours and thin rules.
   ---------------------------------------------------------------------
   1. Design tokens (colours, fonts, sizes)
   2. Reset & base
   3. Typography
   4. Buttons & icons
   5. Cards, tags, badges, flags
   6. Loading screen
   7. Page transitions
   8. Utilities
   9. Reduced motion
   ===================================================================== */


/* ---------------------------------------------------------------------
   1. DESIGN TOKENS
   Change a colour here and it changes everywhere on the site.
   --------------------------------------------------------------------- */
:root {
  /* Paper */
  --bg-0: #fbf7f0;
  --bg-1: #f4eee4;
  --bg-2: #ebe2d4;

  /* Surfaces: solid paper, no see-through glass */
  --surface: #fffdf9;
  --surface-strong: #ffffff;
  --border: #e2d8cb;           /* thin rules and card edges */
  --border-input: #c9bbad;     /* a little darker, for buttons and fields */
  --border-strong: #d9a9c1;    /* magenta-tinted, for hover */

  /* Ink */
  --text: #2b2125;
  --text-muted: #574a50;
  --text-dim: #6e5f66;

  /* Magenta */
  --brand-50:  #fbeff5;
  --brand-100: #f5d9e7;
  --brand-300: #d97aab;
  --brand:     #b4236e;
  --brand-600: #93195a;
  --brand-800: #5f0f3a;

  /* Coin gold: only for the few coin drawings */
  --gold-50:  #fff7da;
  --gold-200: #f6e27a;
  --gold:     #d4af37;
  --gold-600: #b8860b;
  --gold-800: #6e5209;

  /* Accent: magenta by default. The country page swaps this for the
     country's own "accentColor" from info.json. */
  --accent: var(--brand);
  --accent-soft: color-mix(in oklab, var(--accent) 9%, white);
  --accent-line: color-mix(in oklab, var(--accent) 30%, white);
  --accent-text: color-mix(in oklab, var(--accent) 72%, #2b2125);   /* darker, easy to read on cream */

  /* Fonts: Newsreader for headings, Atkinson Hyperlegible for everything
     else (it was designed to be easy to read for people with low vision) */
  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-body: "Atkinson Hyperlegible", Verdana, "Segoe UI", sans-serif;

  /* Shapes: small, squared corners */
  --radius-sm: 2px;
  --radius: 4px;
  --radius-lg: 6px;
  --radius-pill: 4px;

  /* Shadows: barely there, like paper resting on a table */
  --shadow-sm: 0 1px 2px rgba(43, 33, 37, 0.06);
  --shadow: 0 1px 2px rgba(43, 33, 37, 0.05), 0 8px 24px -14px rgba(43, 33, 37, 0.25);
  --shadow-glow: var(--shadow);

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 150ms;
  --dur: 250ms;
  --dur-slow: 500ms;

  /* Spacing */
  --gutter: clamp(16px, 4vw, 40px);
  --content-width: 1200px;

  color-scheme: light;
}


/* ---------------------------------------------------------------------
   2. RESET & BASE
   --------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #c9bbad transparent;
}

html {
  font-size: 112.5%;   /* 18px: comfortable to read */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
svg,
canvas {
  display: block;
  max-width: 100%;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

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

/* :where() gives this reset zero priority, so any class can override it */
:where(ul[class], ol[class], dl[class], dd) {
  margin: 0;
  padding: 0;
  list-style: none;
}

::selection {
  background: var(--brand-100);
  color: var(--text);
}

/* One consistent, clearly visible keyboard focus ring */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

:focus:not(:focus-visible) {
  outline: none;
}

[hidden] {
  display: none !important;
}


/* ---------------------------------------------------------------------
   3. TYPOGRAPHY
   --------------------------------------------------------------------- */
h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.005em;
  text-wrap: balance;
}

p {
  margin: 0;
  text-wrap: pretty;
}

/* Small label above a heading, e.g. "Currency", set in italic like a printed caption */
.eyebrow {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-style: italic;
  font-weight: 400;
  line-height: 1.3;
  color: var(--accent-text);
}


/* ---------------------------------------------------------------------
   4. BUTTONS & ICONS
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 44px;
  padding: 0.55em 1.1em;
  font: 700 0.95rem/1.2 var(--font-body);
  white-space: nowrap;
  text-decoration: none;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  transition:
    background-color var(--dur) ease,
    border-color var(--dur) ease,
    color var(--dur) ease;
}

.btn:hover {
  color: var(--brand-600);
  border-color: var(--brand);
}

.btn:active {
  background: var(--bg-1);
}

/* Solid magenta button (the main action) */
.btn-primary {
  color: #ffffff;
  background: var(--brand);
  border-color: var(--brand);
}

.btn-primary:hover {
  color: #ffffff;
  background: var(--brand-600);
  border-color: var(--brand-600);
}

.btn-primary:active {
  background: var(--brand-800);
}

/* Quieter button */
.btn-ghost {
  background: var(--surface);
}

/* Square icon-only button (zoom, arrows) */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  transition:
    border-color var(--dur) ease,
    color var(--dur) ease,
    background-color var(--dur) ease;
}

.icon-btn:hover {
  color: var(--brand);
  border-color: var(--brand);
}

.icon-btn:active {
  background: var(--bg-1);
}

.icon-btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* Line icons draw with the text colour */
.btn svg,
.icon-btn svg {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

svg .fill {
  fill: currentColor;
  stroke: none;
}


/* ---------------------------------------------------------------------
   5. CARDS, TAGS, BADGES, FLAGS
   --------------------------------------------------------------------- */
.card {
  position: relative;
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* Small tag, e.g. "¥500" */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.3em 0.7em;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
}

/* Small label, e.g. "Coin" / "Banknote" */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25em 0.55em;
  font: 700 0.8rem/1.2 var(--font-body);
  color: var(--brand-600);
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  border-radius: var(--radius-sm);
}

.badge--banknote {
  color: #1d6b57;
  background: #edf6f2;
  border-color: #c7e3d8;
}

/* Small rectangular flag with a thin edge */
.flag {
  flex: none;
  width: 30px;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 1px rgba(43, 33, 37, 0.18);
  background: var(--bg-2);
}


/* ---------------------------------------------------------------------
   6. LOADING SCREEN
   --------------------------------------------------------------------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-content: center;
  justify-items: center;
  background: var(--bg-0);
  transition:
    opacity 0.4s ease,
    visibility 0.4s ease;
}

.loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-text {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-style: italic;
  color: var(--text-muted);
}

/* Soft pulse used while a photo is loading */
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}


/* ---------------------------------------------------------------------
   7. PAGE TRANSITIONS
   A quick, plain fade between pages. Modern browsers do it themselves;
   older ones get a fade-in, and JS adds .is-leaving to fade out.
   --------------------------------------------------------------------- */
@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: page-out 0.2s ease both;
}

::view-transition-new(root) {
  animation: page-in 0.3s ease both;
}

@keyframes page-out {
  to { opacity: 0; }
}

@keyframes page-in {
  from { opacity: 0; }
}

@supports not (view-transition-name: none) {
  body {
    animation: page-in 0.3s ease both;
  }
}

body.is-leaving {
  opacity: 0;
  transition: opacity 0.25s ease;
}


/* ---------------------------------------------------------------------
   8. UTILITIES
   --------------------------------------------------------------------- */
/* Hidden on screen but still read out by screen readers */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.container {
  width: min(var(--content-width), 100% - 2 * var(--gutter));
  margin-inline: auto;
}

.noscript {
  position: fixed;
  inset: auto 0 0;
  z-index: 2000;
  margin: 0;
  padding: 1rem;
  text-align: center;
  color: #ffffff;
  background: var(--brand);
}


/* ---------------------------------------------------------------------
   9. REDUCED MOTION
   If the visitor's device asks for less animation, turn it off.
   --------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }

  @view-transition {
    navigation: none;
  }
}
