/* ==========================================================================
   The Song of Saoirse - shared foundations
   --------------------------------------------------------------------------
   Everything every page on the site needs: the typeface, the colour palette,
   the twilight background, the page container, the title, the knot and the
   buttons. Anything used by only one page belongs in that page's own
   stylesheet, not here.

   Loaded FIRST, before the page stylesheet, so a page can override it.
   ========================================================================== */

/* Display face: the title and the dated headings. */
@font-face {
  font-family: "Uncial Antiqua";
  src: url("fonts/UncialAntiqua-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* Body face. Static single-weight cuts, not the variable font, which carries
   a whole weight axis nobody here uses and costs four times as much. */
@font-face {
  font-family: "EB Garamond";
  src: url("fonts/EBGaramond-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "EB Garamond";
  src: url("fonts/EBGaramond-Italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  /* Sky */
  --night:      #0b0820;
  --dusk:       #171043;
  --horizon:    #2b1f63;

  /* Léas */
  --leas:       #b681ff;
  --leas-soft:  #d7bcff;
  --leas-deep:  #6d3fd6;

  /* Wood */
  --wood-lit:   #f2c78c;
  --wood:       #c98f4f;
  --wood-mid:   #a86c34;
  --wood-dark:  #6d3f1c;
  --bore:       #2a1608;

  /* Text */
  --text:       #ece7ff;
  --text-dim:   #a79dd0;

  --focus:      #ffd88a;

  /* Typefaces. Uncial for display, Garamond for everything that is read. */
  --display: "Uncial Antiqua", "Iowan Old Style", Palatino, Georgia, serif;
  --body:    "EB Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;

  --gutter:     14px;
}

* { box-sizing: border-box; }

html {
  /* Garamond runs small for its nominal size. Moving the root up from the
     16px default lifts every rem on the site by the same amount, rather
     than second-guessing each one. */
  font-size: 17px;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--night);
  /* Horizon glow low on the page, a cool wash above it. No card grids. */
  background-image:
    radial-gradient(120% 62% at 50% 118%, var(--horizon) 0%, rgba(43,31,99,0) 62%),
    radial-gradient(90% 55% at 50% -10%, #241a57 0%, rgba(36,26,87,0) 70%),
    linear-gradient(180deg, var(--night) 0%, var(--dusk) 55%, #120d30 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--body);
  font-size: 1rem;
  /* Old-style figures are lovely in running prose and useless in a grid
     reference, so lining, tabular digits are switched on where they matter,
     not here. */
  line-height: 1.56;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

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

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.page {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top, 0px) + 26px)
    var(--gutter)
    calc(env(safe-area-inset-bottom, 0px) + 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  min-height: 100vh;
  min-height: 100svh;
}

.masthead { text-align: center; }

.title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2rem, 9.5vw, 3rem);
  line-height: 1.12;
  margin: 0;
  color: #f4ecff;
  letter-spacing: 0.005em;
  text-shadow:
    0 0 26px rgba(182, 129, 255, 0.42),
    0 2px 0 rgba(0, 0, 0, 0.35);
}

.knot {
  display: block;
  width: 170px;
  height: 65px;
  margin: 6px auto 8px;
  fill: none;
  stroke: var(--leas);
  stroke-width: 2.1;
  stroke-linecap: round;
  opacity: 0.45;
}

/* Pages with the knot get their spacing from it. Pages without one need
   the title and the intro pushed apart by hand. */
.title + .intro { margin-top: 14px; }

.intro {
  margin: 0;
  max-width: 34ch;
  margin-inline: auto;
  color: var(--text-dim);
  font-size: 1rem;
  text-wrap: balance;
}


/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.controls { display: flex; justify-content: center; }

.btn {
  -webkit-appearance: none;
  appearance: none;
  min-height: 48px;
  padding: 12px 26px;
  border-radius: 999px;
  border: 1.5px solid rgba(182, 129, 255, 0.55);
  background: rgba(182, 129, 255, 0.1);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 160ms ease, border-color 160ms ease;
}

.btn:hover { background: rgba(182, 129, 255, 0.2); }
.btn:active { background: rgba(182, 129, 255, 0.3); }

.btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.btn-quiet {
  border-color: rgba(236, 231, 255, 0.3);
  background: transparent;
  color: var(--text-dim);
}

.btn-copy { margin-top: 12px; }

/* --------------------------------------------------------------------------
   Links and prose
   -------------------------------------------------------------------------- */

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

a:hover { color: #fff; }

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

/* A readable column. Long prose gets uncomfortable past about 34em. */
.prose {
  width: 100%;
  max-width: 34em;
  margin-inline: auto;
}

.prose p { margin: 0 0 1em; }

/* The way back, on every page but the front one. Generous tap target. */
.backlink {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 4px;
  color: var(--text-dim);
  font-size: 0.95rem;
  text-decoration: none;
}

.backlink:hover { color: var(--text); }
.backlink::before { content: "\2190"; font-size: 1.1em; }

/* --------------------------------------------------------------------------
   Reduced motion. Pages add their own rules on top of this one.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
