:root {
  --bg: #0f1519;
  --panel: #151e24;
  --line: #24313a;
  --ink: #e7edf1;
  --mut: #90a0ac;
  --accent: #d4a72c;
  --danger: #e5484d;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: "Newsreader", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}

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

/* The hidden attribute has to beat author styles. #gate sets display:grid,
   and an ID selector outranks the browser's built in [hidden]{display:none},
   so without this the email gate stays on screen after a successful sign in
   and the document renders below it, which reads as the button doing nothing. */
[hidden] { display: none !important; }

#gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card {
  width: min(430px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 36px 32px 28px;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 14px;
}

.gate-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 28px;
  line-height: 1.2;
  margin: 0 0 10px;
}

.gate-sub {
  color: var(--mut);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 24px;
}

.field-label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mut);
  margin-bottom: 8px;
}

#email {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 16px;
  padding: 12px 14px;
  outline: none;
}

#email:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(212, 167, 44, 0.18);
}

#gate-btn {
  width: 100%;
  margin-top: 14px;
  background: var(--accent);
  color: #14100a;
  border: 0;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 14px;
  cursor: pointer;
}

#gate-btn:hover { filter: brightness(1.06); }
#gate-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
#gate-btn[disabled] { opacity: 0.6; cursor: default; }

.gate-error {
  color: var(--danger);
  font-size: 13px;
  margin: 12px 0 0;
}

.gate-note {
  color: var(--mut);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  border-top: 1px solid var(--line);
  margin: 24px 0 0;
  padding-top: 16px;
}

/* ---------- Reading room ---------- */

.strip {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: rgba(15, 21, 25, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.strip-left, .strip-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}

.strip-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.who, .clock {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--mut);
  white-space: nowrap;
}

.clock { color: var(--accent); }

.pages {
  max-width: 900px;
  margin: 0 auto;
  padding: 64px 12px 80px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.page {
  position: relative;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
}

.page img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Watermark tile is set from JS with the viewer's email */
.wm {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-repeat: repeat;
  opacity: 0.9;
}

.pagenum {
  position: absolute;
  right: 8px;
  bottom: 6px;
  font-family: var(--mono);
  font-size: 10px;
  color: rgba(0, 0, 0, 0.45);
  background: rgba(255, 255, 255, 0.6);
  border-radius: 3px;
  padding: 1px 5px;
  pointer-events: none;
}

/* Blur everything while the tab is hidden or backgrounded */
.shield-note {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  place-items: center;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--mut);
  background: rgba(15, 21, 25, 0.55);
}

body.shield .pages { filter: blur(16px); }
body.shield .shield-note { display: grid; }

#printnote { display: none; }

@media print {
  #app, #gate { display: none !important; }
  #printnote {
    display: block;
    font-family: var(--sans);
    font-size: 16px;
    padding: 40px;
    color: #000;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .gate-card { animation: rise 0.35s ease-out; }
  @keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
  }
}
