/* ============================================================================
   Pirabits — site.css
   Hand-inked parchment aesthetic. Two surfaces:
     • the chart (index.html)  — the map of voyages, the front door
     • the player (play.html)  — a sailed-into experiment, full-bleed
   Tokens lifted from the doodle for cohesion.
   ========================================================================== */

:root {
  /* Core palette (from the doodle) */
  --ink:        #1a1a1a;
  --paper:      #f5f0e8;
  --sea:        #d0caba;
  --frame:      #1e1b16;

  /* Derived */
  --ink-12:     rgba(26, 26, 26, 0.12);
  --ink-22:     rgba(26, 26, 26, 0.22);
  --ink-45:     rgba(26, 26, 26, 0.45);
  --paper-edge: #e6ddcb;
  --paper-deep: #d8cdb6;

  /* Type */
  --font-log:   "Courier New", Courier, monospace;   /* the game's voice */
  --font-chart: Georgia, "Times New Roman", serif;   /* the cartographer */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

/* ============================================================================
   PLAYER — play.html — a sailed-into experiment, full-bleed
   ========================================================================== */

body.player {
  background: var(--frame);
  overflow: hidden;
  font-family: var(--font-log);
}

#stage { position: fixed; inset: 0; }

#current {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--frame);
}

/* Calm parchment splash while the experiment mounts */
#splash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 120% at 50% 40%, var(--paper) 0%, var(--paper-edge) 100%);
  color: var(--ink);
  font-family: var(--font-log);
  letter-spacing: 0.28em;
  font-size: 12px;
  text-transform: uppercase;
  z-index: 20;
  transition: opacity 0.6s ease;
}
#splash.is-hidden { opacity: 0; pointer-events: none; }
#splash .mark { animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* Empty / error state */
#fallback {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-log);
  text-align: center;
  padding: 2rem;
  z-index: 30;
}
#fallback.is-shown { display: flex; }
#fallback a { color: var(--ink); }

/* Corner overlays — near-invisible until sought (stillness-as-default) */
.overlay {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  font-family: var(--font-log);
  color: var(--paper);
  user-select: none;
}
.overlay--wordmark {
  left: 18px;
  bottom: 14px;
  font-size: 12px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  opacity: 0.32;
  transition: opacity 0.4s ease;
}
.overlay--wordmark:hover { opacity: 0.7; }

.overlay--back {
  left: 16px;
  top: 14px;
  pointer-events: auto;
}
.overlay--back a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--paper);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  opacity: 0.42;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.overlay--back a:hover { opacity: 0.95; transform: translateX(-2px); }
.overlay--back svg { width: 22px; height: 22px; display: block; }
.overlay--back .needle { transform-origin: 11px 11px; animation: drift 11s ease-in-out infinite; }
@keyframes drift { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(9deg); } }

/* ============================================================================
   CHART — index.html — the map of voyages (the front door)
   ========================================================================== */

body.chart {
  min-height: 100vh;
  font-family: var(--font-chart);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(140% 120% at 50% 0%, rgba(245,240,232,0) 55%, rgba(26,26,26,0.10) 100%),
    radial-gradient(80% 70% at 50% 45%, var(--paper) 0%, var(--paper-edge) 78%, var(--paper-deep) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-attachment: fixed;
}

.chart__wrap {
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
  min-height: 100vh;
  padding: clamp(20px, 4vw, 48px);
}

/* Inked map border with notched corners */
.chart__border {
  position: absolute;
  inset: clamp(12px, 2.4vw, 26px);
  border: 2px solid var(--ink);
  box-shadow: inset 0 0 0 5px var(--paper), inset 0 0 0 7px var(--ink-22);
  pointer-events: none;
}
.chart__border::before,
.chart__border::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border: 2px solid var(--ink);
}
.chart__border::before { top: -8px; left: -8px; border-right: 0; border-bottom: 0; }
.chart__border::after  { bottom: -8px; right: -8px; border-left: 0; border-top: 0; }

/* Faint lat/long grid */
.chart__grid {
  position: absolute;
  inset: clamp(12px, 2.4vw, 26px);
  pointer-events: none;
  opacity: 0.5;
  background-image:
    repeating-linear-gradient(0deg,  transparent 0 71px, var(--ink-12) 71px 72px),
    repeating-linear-gradient(90deg, transparent 0 71px, var(--ink-12) 71px 72px);
}

/* Header */
.chart__head {
  position: relative;
  text-align: center;
  padding: clamp(18px, 4vw, 40px) 1rem clamp(8px, 2vw, 18px);
}
.chart__kicker {
  font-family: var(--font-log);
  font-size: 11px;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--ink-45);
}
.chart__title {
  font-family: var(--font-chart);
  font-style: italic;
  font-weight: 700;
  font-size: clamp(2rem, 6vw, 3.6rem);
  line-height: 1;
  margin: 0.35em 0 0.15em;
  letter-spacing: 0.01em;
}
.chart__title::first-letter { font-size: 1.25em; }
.chart__sub {
  font-family: var(--font-log);
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-45);
}

/* The sea field where features sit */
.chart__field {
  position: relative;
  min-height: 62vh;
  margin-top: clamp(12px, 3vw, 28px);
}

/* Route line layer (SVG injected by JS) */
.chart__routes {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: visible;
}

/* A feature = a clickable voyage marker (island, maelstrom, port, ...) */
.feature {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 200px;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.feature:hover { transform: translate(-50%, calc(-50% - 6px)); }
.feature__art { width: 100px; height: 80px; overflow: visible; }
.feature:hover .feature__art { filter: drop-shadow(0 4px 0 var(--ink-12)); }

.feature__title {
  font-family: var(--font-chart);
  font-style: italic;
  font-size: 1.2rem;
  line-height: 1.1;
}
.feature__blurb {
  font-family: var(--font-log);
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--ink-45);
  max-width: 190px;
}
.feature__tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 2px;
}
.feature__tag {
  font-family: var(--font-log);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--ink-45);
  border-radius: 2px;
  padding: 1px 5px;
  color: var(--ink);
}

/* Newest voyage — subtle "fresh ink" pill (shown only when 2+ voyages) */
.feature__flag {
  font-family: var(--font-log);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper);
  padding: 2px 7px;
  border-radius: 2px;
}

/* Compass rose */
.chart__compass {
  position: absolute;
  right: clamp(28px, 5vw, 60px);
  bottom: clamp(28px, 5vw, 60px);
  width: clamp(64px, 9vw, 104px);
  height: clamp(64px, 9vw, 104px);
  opacity: 0.8;
  pointer-events: none;
}
.chart__compass .needle { transform-origin: 50% 50%; animation: drift 14s ease-in-out infinite; }

/* "here be code" doodle, set quietly in a corner */
.chart__monster {
  position: absolute;
  left: clamp(24px, 5vw, 64px);
  bottom: clamp(30px, 6vw, 70px);
  width: clamp(120px, 18vw, 210px);
  opacity: 0.5;
  pointer-events: none;
}
.chart__monster figcaption {
  font-family: var(--font-chart);
  font-style: italic;
  font-size: 12px;
  text-align: center;
  color: var(--ink-45);
  margin-top: 2px;
}

/* Narrow screens: features flow in a column rather than scatter */
@media (max-width: 640px) {
  .chart__field {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 36px;
    min-height: auto;
    padding: 8px 0 24px;
  }
  .feature {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    transform: none;
    width: min(280px, 86vw);
  }
  .feature:hover { transform: translateY(-4px); }
  .chart__routes, .chart__monster { display: none; }
  .chart__compass { opacity: 0.5; }
}
