:root {
  --bg: #000;
  --fg: #ececec;
  --muted: #8a8a8a;
  --faint: #3a3a3a;
  --line: #1f1f1f;
  --accent: #fefb53;
  --error: #ff6b5a;
  --font: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --gutter: max(20px, env(safe-area-inset-left));
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

::selection { background: var(--accent); color: #000; }

a { color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- gate ---------- */

.gate {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px var(--gutter);
}

.gate-form {
  --logo-width: min(240px, 60vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  /* nudge the optical centre slightly above the middle */
  margin-top: -6vh;
}

.gate-logo {
  display: block;
  width: var(--logo-width);
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.gate-input {
  /* as wide as the yellow part of the logo: 1004 of the image's 1290px, the rest is padding */
  width: calc(var(--logo-width) * 1004 / 1290);
  margin-top: 4px;
  padding: 10px 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--faint);
  border-radius: 0;
  color: var(--fg);
  font: 16px var(--font);
  letter-spacing: 0.2em;
  text-align: center;
  caret-color: var(--accent);
  outline: none;
  transition: border-color 0.2s;
}
.gate-input:focus { border-bottom-color: var(--accent); }

.gate-error {
  min-height: 1.6em;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.shake { animation: shake 0.4s; }
@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ---------- book ---------- */

.book {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: max(40px, env(safe-area-inset-top)) var(--gutter) max(80px, env(safe-area-inset-bottom));
  animation: fade 0.5s ease both;
}

@keyframes fade { from { opacity: 0; } }

.book-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 40px;
}

.book-logo {
  width: 150px;
  height: auto;
}

.notice {
  max-width: 440px;
  margin: 16px 0 0;
  color: var(--accent);
  font-size: 13px;
  text-align: center;
}

.meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- sign ---------- */

.sign {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-bottom: 48px;
  border-bottom: 1px solid var(--line);
}

.button {
  appearance: none;
  padding: 12px 22px;
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 0;
  color: var(--accent);
  font: 13px var(--font);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.button:hover, .button:focus-visible { background: var(--accent); color: #000; outline: none; }
.button:disabled { opacity: 0.5; cursor: default; }

.button-primary { background: var(--accent); color: #000; }
.button-primary:hover, .button-primary:focus-visible { background: #fff; border-color: #fff; }

.button-quiet { border-color: transparent; color: var(--muted); }
.button-quiet:hover, .button-quiet:focus-visible { background: transparent; color: var(--fg); }

.sign-form {
  width: 100%;
  text-align: left;
}

.field {
  display: block;
  margin-bottom: 28px;
}

.label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.field input,
.field textarea {
  display: block;
  width: 100%;
  padding: 8px 0 10px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--faint);
  border-radius: 0;
  color: var(--fg);
  font: 16px/1.5 var(--font);
  caret-color: var(--accent);
  outline: none;
  resize: none;
  overflow: hidden;
  transition: border-color 0.2s;
}
.field input::placeholder,
.field textarea::placeholder { color: #555; }
.field input:focus,
.field textarea:focus { border-bottom-color: var(--accent); }
.field .invalid { border-bottom-color: var(--error); }

.form-error {
  min-height: 1.6em;
  margin: -12px 0 12px;
  color: var(--error);
  font-size: 13px;
}

.sign-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* the email sits apart from the answers: it is never shown to anyone */
.field-email {
  margin-top: 48px;
}

/* Safari paints autofilled fields yellow and ignores `background`; an inset shadow covers it. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
textarea:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--fg);
  -webkit-box-shadow: 0 0 0 100px var(--bg) inset;
  box-shadow: 0 0 0 100px var(--bg) inset;
  caret-color: var(--accent);
  /* the yellow also fades in on some versions; outrun it */
  transition: background-color 100000s ease-in-out 0s;
}

/* ---------- entries ---------- */

.entries {
  list-style: none;
  margin: 0;
  padding: 0;
}

.entry {
  padding: 36px 0;
  border-bottom: 1px solid var(--line);
}

.entry-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.entry-own .entry-no { color: var(--accent); }

.who {
  margin: 0 0 24px;
  line-height: 1.5;
}

.who-name {
  display: block;
  font-size: 18px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* your own entry while it waits for the email link */
.entry-note {
  margin-top: 24px;
  padding: 14px 16px 6px;
  border-left: 2px solid var(--accent);
  background: #0d0d0d;
  font-size: 13px;
}
.entry-note p { margin: 0; }
.entry-note .note-flash { margin-bottom: 8px; color: var(--accent); }

.entry-status {
  color: var(--muted);
  font-size: 13px;
}

.entry-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 20px;
  margin-top: 24px;
}

.confirm-text {
  flex-basis: 100%;
  color: var(--fg);
  font-size: 13px;
}

.text-button {
  appearance: none;
  padding: 8px 0;
  background: none;
  border: 0;
  color: var(--muted);
  font: 12px var(--font);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.text-button:hover, .text-button:focus-visible { color: var(--accent); outline: none; }
.text-button-accent { color: var(--accent); }
.text-button-accent:hover, .text-button-accent:focus-visible { color: #fff; }
.text-button-danger { color: var(--error); }
.text-button-danger:hover, .text-button-danger:focus-visible { color: #fff; }
.text-button:disabled { opacity: 0.5; cursor: default; }
a.text-button { display: inline-block; text-decoration: none; }

.contact { margin-top: 12px; }
#sign-open[hidden] + .contact { margin-top: 0; }


.achievement {
  margin: -12px 0 20px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.part { margin: 0 0 18px; }
.part:last-child { margin-bottom: 0; }

.part dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.part dd {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.empty {
  padding: 48px 0;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

/* ---------- footer + privacy & cookies ---------- */

.book-foot {
  margin-top: 48px;
  text-align: center;
}

.modal {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100svh - 32px);
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--faint);
  border-radius: 0;
  font-size: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal[open] { animation: fade 0.2s ease both; }
.modal::backdrop { background: rgba(0, 0, 0, 0.8); }

.modal-inner { padding: 20px 24px 8px; }

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}
.modal-head .label { margin: 0; color: var(--fg); font-weight: 400; }

.modal h3 { margin: 0 0 6px; font-weight: 400; }
.modal p { margin: 0 0 20px; overflow-wrap: anywhere; }

body:has(.modal[open]) { overflow: hidden; }

/* ---------- jump to top / bottom ---------- */

.jump {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.jump-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid var(--faint);
  border-radius: 0;
  color: var(--accent);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s, border-color 0.15s;
}
.jump-button.visible { opacity: 1; pointer-events: auto; transform: none; }
.jump-button:hover, .jump-button:focus-visible { border-color: var(--accent); outline: none; }

.jump-button svg {
  width: 16px;
  height: 8px;
  fill: currentColor;
  shape-rendering: crispEdges;
}
.jump-down svg { transform: rotate(180deg); }

@media (min-width: 700px) {
  body { font-size: 16px; }
  .book { padding-top: 72px; }
  .book-logo { width: 180px; }
  .entry { padding: 44px 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
