/* ==========================================================================
   plessi.us — een inscriptie in steen
   Geen framework, geen build-stap. Alles in CSS-variabelen.
   ========================================================================== */

/* --- Kleuren & tokens ---------------------------------------------------- */

:root {
  color-scheme: light dark;

  /* steen / travertijn, licht thema */
  --stone:      #e9e2d4;
  --stone-deep: #ddd3bf;
  --ink:        #2e2820;
  --ink-soft:   #5c5244;
  --bronze:     #8a6b3a;   /* ornament — decoratief */
  --accent:     #6f5326;   /* links — contrast 5.5:1 */

  /* gebeiteld reliëf: licht van linksboven */
  --carve-hi:   rgba(255, 255, 255, .78);
  --carve-lo:   rgba(58, 44, 24, .40);

  --grain-opacity: .20;
  --grain-blend: multiply;

  --measure: min(92vw, 1500px);
  --fade: .45s;
}

@media (prefers-color-scheme: dark) {
  :root {
    --stone:      #16130f;
    --stone-deep: #201b14;
    --ink:        #ded3bd;
    --ink-soft:   #a2947c;
    --bronze:     #c9a463;
    --accent:     #d9b978;

    --carve-hi:   rgba(0, 0, 0, .75);
    --carve-lo:   rgba(255, 255, 255, .16);

    --grain-opacity: .16;
    --grain-blend: soft-light;
  }
}

/* --- Basis --------------------------------------------------------------- */

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

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--ink);
  background-color: var(--stone);
  /* travertijn-vlekken, puur met gradients — geen afbeeldingen */
  background-image:
    radial-gradient(60% 45% at 18% 12%, var(--stone-deep) 0%, transparent 70%),
    radial-gradient(55% 40% at 82% 78%, var(--stone-deep) 0%, transparent 72%),
    radial-gradient(40% 30% at 50% 50%, rgba(255, 255, 255, .08) 0%, transparent 75%);
  background-attachment: fixed;
  font-family: "Cinzel", "Trajan Pro", Optima, "Palatino Linotype", Palatino,
               "Book Antiqua", Georgia, "Times New Roman", serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

/* fijne steenkorrel als losse laag */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
}

/* --- Het paneel ---------------------------------------------------------- */

.stone {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(1.5rem, 6vw, 4rem) 1rem;
}

.plaque {
  width: var(--measure);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* --- De inscriptie ------------------------------------------------------- */

.carve { position: relative; }

.inscription {
  margin: 0;
  font-weight: 600;
  font-size: clamp(1.75rem, 8.4vw, 3rem);
  line-height: 1.1;
  letter-spacing: .14em;
  padding-left: .14em;           /* compenseert de spatie ná de laatste letter */
  color: var(--ink);
  text-shadow:
     0  1px 0   var(--carve-hi),
     0 -1px 1px var(--carve-lo),
     1px 1px 2px rgba(0, 0, 0, .06);

  display: flex;
  flex-direction: column;        /* mobiel: één woord per regel */
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.word { white-space: nowrap; }

.sep {
  color: var(--bronze);
  user-select: none;
  -webkit-user-select: none;
  font-size: .55em;
  line-height: 1;
  margin: .18em 0;
  opacity: .8;
}

@media (min-width: 900px) {
  .inscription {
    flex-direction: row;
    align-items: baseline;
    font-size: clamp(2rem, 3vw, 3.25rem);
  }
  .sep {
    font-size: 1em;
    line-height: inherit;
    margin: 0 .38em;
  }
}

.inscription--small {
  font-size: clamp(1.5rem, 7vw, 2.5rem);
}
@media (min-width: 900px) {
  .inscription--small { font-size: clamp(1.75rem, 2.4vw, 2.5rem); }
}

/* MCMXCI ⇄ 1991: beide in dezelfde grid-cel, dus geen layout-shift */
.year {
  display: inline-grid;
  vertical-align: baseline;
}
.year > span {
  grid-area: 1 / 1;
  justify-self: center;
  transition: opacity var(--fade) ease;
}
/* niet mee-kopiëren: de inscriptie zelf is MCMXCI */
.year-arabic {
  opacity: 0;
  user-select: none;
  -webkit-user-select: none;
}
.year:hover  .year-roman,
.year:focus-visible .year-roman,
.year.is-flipped .year-roman { opacity: 0; }
.year:hover  .year-arabic,
.year:focus-visible .year-arabic,
.year.is-flipped .year-arabic { opacity: 1; }

/* --- Ornamenten ---------------------------------------------------------- */

.wreath {
  width: clamp(3rem, 9vw, 4.75rem);
  height: auto;
  color: var(--bronze);
  opacity: .72;
  margin-bottom: clamp(.75rem, 2.5vw, 1.5rem);
}

.rule {
  width: min(100%, 26rem);
  height: auto;
  color: var(--bronze);
  opacity: .7;
  margin-top: clamp(1rem, 3vw, 1.75rem);
}

/* --- Contactregel -------------------------------------------------------- */

.contact {
  margin: clamp(1.25rem, 3.5vw, 2rem) 0 0;
  font-size: clamp(.8125rem, 2.4vw, .9375rem);
  letter-spacing: .1em;
  color: var(--ink-soft);
}

.link, .contact a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: .28em;
  text-decoration-thickness: from-font;
  border-radius: 2px;
}
.link:hover, .contact a:hover { color: var(--ink); }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.prose {
  margin: clamp(1rem, 3vw, 1.75rem) 0 0;
  max-width: 34rem;
  font-size: clamp(.9375rem, 2.6vw, 1.0625rem);
  line-height: 1.85;
  letter-spacing: .04em;
  color: var(--ink-soft);
  font-style: italic;
}

/* --- Vale (#vale) -------------------------------------------------------- */

.vale {
  position: fixed;
  inset: 0;
  z-index: 3;
  background-color: var(--stone);
  overflow-y: auto;
}

/* ==========================================================================
   Easter eggs
   ========================================================================== */

/* --- Erosie: de inscriptie brokkelt af en herstelt zich ------------------- */

.inscription--ghost {
  position: absolute;
  inset: 0;
  margin: 0;
  pointer-events: none;
  /* losse letters breken anders net even anders af dan de echte regel */
  flex-wrap: nowrap;
}

.is-eroding { opacity: 0; }

/* variant zonder beweging (prefers-reduced-motion) */
.is-faded { opacity: .3; }

.shard {
  display: inline-block;
  animation: crumble 1.15s cubic-bezier(.35, 0, .85, .45) both;
}

@keyframes crumble {
  0%   { transform: none; opacity: 1; filter: blur(0); }
  18%  { transform: translate(calc(var(--dx) * .06), .01em) rotate(calc(var(--rot) * .05)); }
  100% { transform: translate(var(--dx), .95em) rotate(var(--rot)); opacity: 0; filter: blur(4px); }
}

.is-reforming { animation: reform .85s ease-out both; }

@keyframes reform {
  0%   { opacity: 0; filter: blur(5px); transform: translateY(.12em); }
  100% { opacity: 1; filter: blur(0);   transform: none; }
}

/* --- SPQR: de aquila ----------------------------------------------------- */

.spqr {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  gap: 1.25rem;
  padding: 2rem 1rem;
  pointer-events: none;
  background-color: var(--stone);
  background-color: color-mix(in srgb, var(--stone) 94%, transparent);
  animation: aquila-in 2.8s ease-in-out both;
}

.spqr-inner { display: grid; justify-items: center; gap: clamp(1rem, 3vw, 1.75rem); }

.aquila {
  width: clamp(7rem, 26vw, 12rem);
  height: auto;
  color: var(--bronze);
  filter: drop-shadow(0 2px 1px var(--carve-lo));
}

.spqr-text {
  margin: 0;
  font-size: clamp(.875rem, 3.4vw, 1.5rem);
  font-weight: 600;
  letter-spacing: .18em;
  padding-left: .18em;
  color: var(--ink);
  text-shadow: 0 1px 0 var(--carve-hi), 0 -1px 1px var(--carve-lo);
}

@keyframes aquila-in {
  0%   { opacity: 0; transform: scale(.94); }
  14%  { opacity: 1; transform: scale(1); }
  78%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.03); }
}

/* --- Ludus: ALEA IACTA EST ----------------------------------------------- */

.ludus {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 1rem;
  background-color: var(--stone);
  background-color: color-mix(in srgb, var(--stone) 88%, transparent);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.ludus-box {
  width: min(30rem, 100%);
  padding: clamp(1.25rem, 5vw, 2.25rem);
  text-align: center;
  border: 1px solid color-mix(in srgb, var(--bronze) 45%, transparent);
  border-radius: 3px;
  background-color: var(--stone-deep);
  box-shadow: 0 1px 0 var(--carve-hi) inset, 0 18px 48px rgba(0, 0, 0, .22);
}

.ludus-title {
  margin: 0 0 1.25rem;
  font-size: clamp(1.125rem, 4.5vw, 1.5rem);
  font-weight: 600;
  letter-spacing: .2em;
  padding-left: .2em;
  color: var(--ink);
  text-shadow: 0 1px 0 var(--carve-hi), 0 -1px 1px var(--carve-lo);
}

.tesserae {
  display: flex;
  justify-content: center;
  gap: clamp(.6rem, 3vw, 1rem);
  margin-bottom: 1.25rem;
}

.tessera {
  /* procentuele padding zou tegen de flex-container rekenen i.p.v. tegen de
     steen zelf; daarom alles afgeleid van --size. */
  --size: clamp(3.25rem, 17vw, 4.25rem);
  width: var(--size);
  height: var(--size);
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  padding: calc(var(--size) * .15);
  border: 1px solid color-mix(in srgb, var(--bronze) 50%, transparent);
  border-radius: 8px;
  background-color: var(--stone);
  box-shadow: 0 1px 0 var(--carve-hi) inset, 0 6px 14px rgba(0, 0, 0, .16);
}

.tessera.is-rolling { animation: tumble .42s linear infinite; }

.pip {
  width: 74%;
  aspect-ratio: 1;
  place-self: center;
  border-radius: 50%;
  background-color: var(--ink);
  box-shadow: 0 1px 0 var(--carve-hi);
}

@keyframes tumble {
  0%   { transform: translateY(0)      rotate(0deg); }
  25%  { transform: translateY(-14%)   rotate(90deg); }
  50%  { transform: translateY(0)      rotate(180deg); }
  75%  { transform: translateY(-9%)    rotate(270deg); }
  100% { transform: translateY(0)      rotate(360deg); }
}

.ludus-score {
  margin: 0 0 1.5rem;
  font-size: clamp(.75rem, 3vw, .875rem);
  letter-spacing: .14em;
  color: var(--ink-soft);
}
.ludus-score strong { color: var(--ink); font-weight: 600; }
.ludus-venus { color: var(--accent); }

.ludus-actions { display: flex; justify-content: center; gap: .75rem; flex-wrap: wrap; }

.ludus-actions button {
  font: inherit;
  font-weight: 600;
  font-size: clamp(.8125rem, 3vw, .9375rem);
  letter-spacing: .16em;
  padding: .7em 1.4em .7em calc(1.4em + .16em);
  color: var(--ink);
  background-color: var(--stone);
  border: 1px solid color-mix(in srgb, var(--bronze) 55%, transparent);
  border-radius: 3px;
  cursor: pointer;
  box-shadow: 0 1px 0 var(--carve-hi) inset;
}
.ludus-actions button:hover { background-color: var(--stone-deep); border-color: var(--accent); }
.ludus-actions button[disabled] { opacity: .5; cursor: default; }

.ludus-hint {
  margin: 1.25rem 0 0;
  font-size: .75rem;
  letter-spacing: .1em;
  color: var(--ink-soft);
}

/* --- Beweging beperken --------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .spqr { animation: none; }
  .tessera.is-rolling { animation: none; }
}
