:root {
  --ink: #1a1814;
  --paper: #f4f1ea;
  --accent: #8a6d3b;
  --line: #d8d2c4;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over .gate/.viewer display rules below,
   otherwise toggling hidden does nothing and the gate never disappears. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "EB Garamond", Georgia, "Times New Roman", serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Boot loader (prevents a flash of the gate on resume) ---------- */
.boot-mark {
  font-family: "EB Garamond", Georgia, "Times New Roman", serif;
  font-size: 64px;
  color: var(--ink);
  animation: bootpulse 1.2s ease-in-out infinite;
}
@keyframes bootpulse { 0%, 100% { opacity: 0.18; } 50% { opacity: 0.42; } }

/* ---------- Gate ---------- */
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  padding: 48px 40px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.06);
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: 11px;
  color: var(--accent);
  margin: 0 0 14px;
  font-family: "Helvetica Neue", Arial, sans-serif;
}
.gate-card h1 {
  font-size: 38px;
  font-weight: 500;
  margin: 0 0 16px;
  letter-spacing: 0.01em;
}
.lede {
  font-size: 17px;
  line-height: 1.5;
  color: #5b554a;
  margin: 0 0 28px;
}
#gate-form, #code-form { display: flex; flex-direction: column; gap: 12px; }
#gate-form .row { display: flex; gap: 12px; }
#gate-form .row input { flex: 1; min-width: 0; }
.gate-card input {
  padding: 14px 16px;
  border: 1px solid var(--line);
  font-size: 16px;
  font-family: inherit;
  background: #fbfaf7;
}
.gate-card input:focus { outline: none; border-color: var(--accent); }
.gate-card button {
  padding: 14px 16px;
  background: var(--ink);
  color: #fff;
  border: none;
  font-size: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: "Helvetica Neue", Arial, sans-serif;
  transition: background 0.2s;
}
.gate-card button:hover { background: var(--accent); }
.gate-card button:disabled { opacity: 0.5; cursor: progress; }
.code-input {
  text-align: center;
  font-size: 30px;
  letter-spacing: 0.5em;
  text-indent: 0.5em; /* compensate trailing letter-spacing for centering */
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
.code-input::placeholder { letter-spacing: 0.3em; color: #c9c2b2; }
#resend-link { color: var(--accent); text-decoration: underline; cursor: pointer; }

.error {
  color: #a23a2e;
  min-height: 20px;
  font-size: 14px;
  margin: 14px 0 0;
  font-family: "Helvetica Neue", Arial, sans-serif;
}
.fineprint {
  font-size: 12px;
  color: #9a9384;
  margin: 22px 0 0;
  font-family: "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Viewer ---------- */
.viewer { min-height: 100vh; }
.viewer-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: rgba(26, 24, 20, 0.95);
  color: #f4f1ea;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.viewer-id { opacity: 0.7; text-transform: none; letter-spacing: normal; }
.pages {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 80px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.pages .page {
  position: relative;
  margin: 0;
  width: 100%;
  aspect-ratio: 1.414 / 1; /* reserves space so lazy images don't jump the layout */
  background: #e8e3d8 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40"><circle cx="20" cy="20" r="6" fill="%23c9c2b2"/></svg>') center no-repeat;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}
.pages .page img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}
/* per-viewer watermark, stretched to cover the page (SVG viewBox matches aspect) */
.pages .wm {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
