@font-face {
  font-family: "Geist";
  src: url("assets/fonts/Geist.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("assets/fonts/GeistMono.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #08090B;
  --paper: #F1EFEB;
  --ink: #0B0C0E;
  --stone: #8B8F92;
  --ash: #D8D7D2;
  --sans: "Geist", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;
  --gutter: clamp(20px, 4.5vw, 44px);
  --page: clamp(20px, 6.7vw, 96px);
  --logo-height: 20px;
}

@media (min-width: 768px) {
  :root { --logo-height: 24px; }
}

html {
  background: var(--bg);
  overscroll-behavior-y: none;
}

html.paper {
  background: var(--paper);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Field ---------- */

/* Large-viewport height: the field fills the screen even with mobile toolbars
   collapsed (or translucent, as on iOS Safari), so nothing below it shows on
   load. It's also stable while toolbars move, so the grid never rebuilds. */
.hero {
  position: relative;
  height: 100vh;
  height: 100lvh;
  background: var(--bg);
  -webkit-user-select: none;
  user-select: none;
}

#field {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.brand {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + var(--gutter));
  left: calc(env(safe-area-inset-left, 0px) + var(--gutter));
  z-index: 1;
  margin: 0;
  line-height: 0;
}

.brand img {
  display: block;
  height: var(--logo-height);
  width: auto;
}

/* ---------- Decryption band ---------- */

#band {
  display: block;
  width: 100%;
  background: var(--bg);
}

/* ---------- Footer ---------- */

.site-footer {
  padding: 24px var(--page) calc(env(safe-area-inset-bottom, 0px) + 40px);
}

.footer-main {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 56px 48px;
  padding-bottom: 72px;
  border-bottom: 1px solid var(--ash);
}

.footer-logo {
  display: block;
  height: 38px;
  width: auto;
}

.footer-note {
  margin: 44px 0 16px;
  font-size: 15px;
  line-height: 1.4;
}

.signup {
  display: flex;
  gap: 8px;
  width: min(420px, 100%);
}

.signup input,
.signup button {
  height: 50px;
  border-radius: 2px;
  font-size: 14px;
}

.signup input {
  flex: 1;
  min-width: 0;
  padding: 0 16px;
  border: 1px solid #C9C7C2;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
}

.signup input::placeholder {
  color: var(--stone);
}

.signup button {
  padding: 0 22px;
  border: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-weight: 500;
  cursor: pointer;
}

.signup button:disabled {
  opacity: 0.5;
  cursor: default;
}

.signup-status {
  min-height: 18px;
  margin: 12px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
}

.signup-status[data-state="email"],
.signup-status[data-state="error"] {
  color: #A1381A;
}

.signup-fine {
  margin: 4px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--stone);
}

.signup-fine a {
  color: inherit;
  text-underline-offset: 2px;
}

.signup input:focus-visible,
.signup button:focus-visible,
.footer-nav a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.footer-nav {
  display: flex;
  gap: clamp(48px, 9vw, 76px);
}

.footer-nav h2 {
  margin: 0 0 18px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--stone);
}

.footer-nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.footer-nav a {
  color: var(--ink);
  font-size: 15px;
  text-decoration: none;
}

.footer-nav a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-bar {
  display: flex;
  justify-content: space-between;
  gap: 8px 24px;
  flex-wrap: wrap;
  padding-top: 22px;
  font-family: var(--mono);
  font-size: 12px;
  color: #45484B;
}

.footer-bar a {
  color: inherit;
  text-decoration: none;
}

.footer-bar a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Text pages (privacy, confirm) ---------- */

.page {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + var(--gutter)) var(--page) calc(env(safe-area-inset-bottom, 0px) + 40px);
  box-sizing: border-box;
}

.page-logo img {
  display: block;
  height: var(--logo-height);
  width: auto;
}

.page-body {
  flex: 1;
  width: min(640px, 100%);
  padding: clamp(56px, 12vh, 120px) 0 72px;
}

.page-label {
  margin: 0 0 20px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--stone);
}

.page-body h1 {
  margin: 0 0 32px;
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.page-body h2 {
  margin: 48px 0 12px;
  font-size: 17px;
  font-weight: 600;
}

.page-body p,
.page-body li {
  font-size: 15px;
  line-height: 1.6;
}

.page-body ul {
  padding-left: 20px;
}

.page-body a {
  color: var(--ink);
  text-underline-offset: 3px;
}

/* Template placeholders still to be filled in */
.page-body mark {
  background: #E6E1D6;
  color: var(--ink);
  padding: 0 3px;
  font-family: var(--mono);
  font-size: 0.88em;
}

.page-body .signup button {
  margin-top: 8px;
}

.page .footer-bar {
  border-top: 1px solid var(--ash);
}

/* ---------- Admin ---------- */

.admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-who {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--stone);
}

.link-button {
  margin-left: 12px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.admin-main {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  padding: clamp(40px, 8vh, 72px) 0 72px;
}

.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 32px;
}

.admin-head h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 500;
  letter-spacing: -0.02em;
}

.admin-stats {
  margin: 0;
  text-align: right;
}

.admin-stats dt {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--stone);
}

.admin-stats dd {
  margin: 4px 0 0;
  font-family: var(--mono);
  font-size: 28px;
}

.admin-warning {
  margin: 0 0 24px;
  padding: 12px 16px;
  background: #E6E1D6;
  font-size: 14px;
}

.admin code,
.admin-hint code {
  font-family: var(--mono);
  font-size: 0.9em;
}

.admin-grid {
  display: grid;
  gap: 32px;
}

@media (min-width: 960px) {
  .admin-grid { grid-template-columns: 1fr 1fr; }
}

.admin-label {
  display: block;
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--stone);
}

.admin-input {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin-bottom: 20px;
  padding: 12px 14px;
  border: 1px solid #C9C7C2;
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  font: 15px var(--sans);
}

.admin-code {
  height: clamp(320px, 60vh, 640px);
  resize: vertical;
  font: 12px/1.55 var(--mono);
  tab-size: 2;
  white-space: pre;
}

.admin-input:focus-visible,
.admin button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.admin-hint {
  margin: -8px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--stone);
}

.admin-preview-subject {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.admin-preview iframe {
  display: block;
  width: 100%;
  height: clamp(320px, 66vh, 700px);
  border: 1px solid var(--ash);
  background: #fff;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 32px;
}

.admin-actions button:not(.link-button),
.admin-confirm .signup button {
  height: 50px;
  padding: 0 22px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--ink);
  color: var(--paper);
  font: 500 14px var(--sans);
  cursor: pointer;
}

.admin-actions .button-secondary {
  background: transparent;
  color: var(--ink);
}

.admin-actions button:disabled,
.admin-confirm button:disabled {
  opacity: 0.4;
  cursor: default;
}

.admin-confirm {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid var(--ink);
  max-width: 520px;
}

.admin-confirm p {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.5;
}

.admin-confirm .link-button {
  margin: 12px 0 0;
}

.admin-history {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--ash);
}

.admin-history ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.admin-history li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 14px;
}

.admin-history-meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--stone);
}

@media (max-width: 640px) {
  .footer-logo { height: 30px; }
  .footer-note { margin-top: 32px; }
  .footer-bar { flex-direction: column; }
}
