/* ————— DuDe Books. — Print-Room Editorial ————— */

:root {
  --paper: #F3EDE2;
  --ink: #17140F;
  --red: #D63A2A;
  --serif: "Fraunces", Georgia, serif;
  --grot: "Archivo", "Helvetica Neue", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--grot);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* faint paper grain over the cream ground */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 2000;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font: inherit; color: inherit; }

.spec {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.dim { opacity: 0.55; }

/* ————— landing ————— */

.landing {
  position: relative;
  min-height: 100vh;
  display: flex; flex-direction: column;
  padding: clamp(1.25rem, 4vw, 3rem);
  overflow: hidden;
}

.masthead {
  display: flex; align-items: baseline; gap: 1.25rem;
  flex-wrap: wrap;
  z-index: 3;
}

.wordmark {
  font-family: var(--serif);
  font-weight: 900;
  font-variation-settings: "opsz" 144;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1;
  letter-spacing: -0.02em;
}
.wordmark .dot { color: var(--red); }

.pill {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 0.3em 0.9em;
  white-space: nowrap;
}

/* colossal halftone folio */
.folio {
  position: absolute;
  right: -12vw; bottom: -16vh;
  width: min(62vw, 780px);
  height: auto;
  z-index: 1;
  pointer-events: none;
}
.folio-glyph text {
  font-family: var(--serif);
  font-weight: 900;
  font-size: 660px;
  letter-spacing: -0.08em;
}

.plate {
  position: relative; z-index: 3;
  flex: 1;
  display: flex; flex-direction: column; justify-content: center;
  gap: clamp(1.5rem, 3.5vh, 2.5rem);
  max-width: 34rem;
  padding: 3rem 0;
}

.lede {
  font-family: var(--serif);
  font-weight: 400;
  font-variation-settings: "opsz" 60;
  font-size: clamp(1.25rem, 2.6vw, 1.7rem);
  line-height: 1.3;
}

/* die-cut drop window */
.dropzone {
  position: relative;
  background: rgba(23, 20, 15, 0.045);
  box-shadow: inset 0 0 0 1.5px var(--ink);
  padding: 10px;
  cursor: pointer;
  transition: background 120ms ease;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
  background: rgba(214, 58, 42, 0.07);
  outline: none;
}
.dropzone.dragover .trim { border-color: var(--red); }

.trim {
  border: 1.5px dashed var(--ink);
  padding: clamp(1.6rem, 4vh, 2.6rem) 1.5rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.7rem;
  text-align: center;
}

.dz-title {
  font-family: var(--grot); font-weight: 700;
  font-size: 1.05rem; letter-spacing: 0.18em;
}
.dz-sub { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.06em; opacity: 0.6; }

.dz-stamp, .stamp {
  display: inline-block;
  margin-top: 0.4rem;
  background: var(--ink); color: var(--paper);
  font-family: var(--grot); font-weight: 700;
  font-size: 0.78rem; letter-spacing: 0.16em;
  padding: 0.65em 1.4em;
  transition: background 120ms ease;
}
.dropzone:hover .dz-stamp, .stamp:hover { background: var(--red); }
.stamp:disabled { opacity: 0.35; cursor: default; }
.stamp:disabled:hover { background: var(--ink); }
.wide { width: 100%; margin-top: 0.75rem; }

/* registration marks on the die-cut corners */
.reg { position: absolute; width: 11px; height: 11px; pointer-events: none; }
.reg::before, .reg::after { content: ""; position: absolute; background: var(--ink); }
.reg::before { width: 11px; height: 1.5px; top: 5px; }
.reg::after { width: 1.5px; height: 11px; left: 5px; }
.reg-tl { top: -6px; left: -6px; }
.reg-tr { top: -6px; right: -6px; }
.reg-bl { bottom: -6px; left: -6px; }
.reg-br { bottom: -6px; right: -6px; }

.slip {
  border: 1.5px solid var(--red);
  color: var(--red);
  font-family: var(--mono); font-size: 0.75rem;
  letter-spacing: 0.03em; line-height: 1.5;
  padding: 0.7rem 0.9rem;
}

.url-row { display: flex; flex-direction: column; gap: 0.5rem; }
.url-line { display: flex; }
.url-line input {
  flex: 1; min-width: 0;
  background: transparent;
  border: 1.5px solid var(--ink); border-right: none;
  font-family: var(--mono); font-size: 0.8rem;
  padding: 0.65em 0.8em;
}
.url-line input:focus { outline: none; border-color: var(--red); }
.url-line .stamp { margin-top: 0; }

.colophon {
  position: relative; z-index: 3;
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
}

.barcode {
  display: inline-block; height: 22px; width: 148px;
  background: repeating-linear-gradient(90deg,
    var(--ink) 0 2px, transparent 2px 5px,
    var(--ink) 5px 6px, transparent 6px 12px,
    var(--ink) 12px 16px, transparent 16px 19px,
    var(--ink) 19px 20px, transparent 20px 26px,
    var(--ink) 26px 28px, transparent 28px 31px);
}

.corner-note {
  position: absolute;
  right: 0.9rem; top: 50%;
  transform: rotate(90deg) translateX(-50%);
  transform-origin: right top;
  font-family: var(--mono); font-size: 0.62rem;
  letter-spacing: 0.22em;
  opacity: 0.5; z-index: 3;
  white-space: nowrap;
}

/* ————— reader: the stage inverts to ink ————— */

.reader {
  position: fixed; inset: 0;
  background: var(--ink);
  color: var(--paper);
  display: flex; flex-direction: column;
  z-index: 10;
}

.chrome {
  display: flex; align-items: center;
  gap: 0.6rem;
  padding: 0.6rem clamp(0.6rem, 2vw, 1.4rem);
  transition: opacity 300ms ease;
  z-index: 20;
}
.reader.chrome-hidden .chrome { opacity: 0; pointer-events: none; }
.reader.no-book .chrome-bottom, .reader.no-book #btn-share { visibility: hidden; }

.wordmark-small { font-size: 1.15rem; font-weight: 900; }
.doc-spec { opacity: 0.65; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chrome-spacer { flex: 1; }

.tool {
  font-family: var(--mono);
  font-size: 0.72rem; letter-spacing: 0.1em;
  border: 1.5px solid var(--paper);
  color: var(--paper);
  padding: 0.42em 0.75em;
  white-space: nowrap;
  transition: background 100ms ease, color 100ms ease;
}
.tool:hover { background: var(--paper); color: var(--ink); }
.tool.active { background: var(--red); border-color: var(--red); color: var(--paper); }

.stage {
  position: relative; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

.loading {
  position: absolute; inset: 0; z-index: 15;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0.9rem;
  background: var(--ink);
}
.bar { width: min(280px, 60vw); height: 3px; background: rgba(243, 237, 226, 0.2); }
.bar-fill { display: block; height: 100%; width: 0%; background: var(--red); transition: width 150ms linear; }

.notice {
  position: absolute; z-index: 16;
  max-width: 30rem;
  margin: 0 1.5rem;
  font-family: var(--mono); font-size: 0.8rem; line-height: 1.6;
  letter-spacing: 0.02em;
  border: 1.5px solid var(--red);
  padding: 1rem 1.2rem;
  background: var(--ink);
}

.zoom-frame {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  transition: transform 220ms ease;
}

.book-wrap { padding: clamp(0.5rem, 2vh, 1.5rem) 0; }

/* pages */
.pf-page {
  position: relative;
  background: var(--paper);
  overflow: hidden;
}
.pf-page canvas {
  width: 100%; height: 100%; display: block;
}
.pf-page .ph {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: rgba(23, 20, 15, 0.35);
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.12em;
}

.zoom-overlay {
  position: absolute; inset: 0; z-index: 14;
  cursor: grab;
}
.zoom-overlay:active { cursor: grabbing; }

/* bottom chrome */
.chrome-bottom { justify-content: center; }

.counter { min-width: 7.5em; text-align: center; }

.scrubber {
  -webkit-appearance: none; appearance: none;
  flex: 0 1 300px; min-width: 80px;
  height: 2px;
  background: rgba(243, 237, 226, 0.35);
  outline: none;
}
.scrubber::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 8px; height: 16px;
  background: var(--red);
  cursor: pointer;
}
.scrubber::-moz-range-thumb {
  width: 8px; height: 16px; border: none; border-radius: 0;
  background: var(--red); cursor: pointer;
}

.goto-box { display: inline-flex; align-items: stretch; }
.goto-input {
  width: 4.2em;
  background: transparent; color: var(--paper);
  border: 1.5px solid var(--red);
  font-family: var(--mono); font-size: 0.72rem;
  padding: 0.42em 0.5em;
  -moz-appearance: textfield;
}
.goto-input::-webkit-outer-spin-button, .goto-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.goto-input:focus { outline: none; }

/* share panel */
.share-panel {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(23, 20, 15, 0.75);
}
.share-card {
  position: relative;
  background: var(--paper); color: var(--ink);
  width: min(26rem, calc(100vw - 2.5rem));
  padding: 1.5rem 1.5rem 1.1rem;
  border: 1.5px solid var(--ink);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.55);
}
.share-x {
  position: absolute; top: 0.6rem; right: 0.6rem;
  border-color: var(--ink); color: var(--ink);
  font-size: 0.65rem; padding: 0.3em 0.5em;
}
.share-x:hover { background: var(--ink); color: var(--paper); }
.share-note {
  font-size: 0.86rem; line-height: 1.55;
  margin: 0.8rem 0 0.2rem;
}
.share-card input[type="url"], .share-card input[type="password"] {
  width: 100%; margin-top: 0.75rem;
  background: transparent;
  border: 1.5px solid var(--ink);
  font-family: var(--mono); font-size: 0.78rem;
  padding: 0.6em 0.7em;
}
.share-card input[type="url"]:focus { outline: none; border-color: var(--red); }
.share-feedback { margin-top: 0.7rem; min-height: 1.2em; color: var(--red); opacity: 1; }

/* ————— narrow screens ————— */
@media (max-width: 640px) {
  .folio { right: -30vw; bottom: -10vh; width: 100vw; }
  .corner-note { display: none; }
  .doc-spec { display: none; }
  .counter { min-width: 0; }
  .chrome { flex-wrap: wrap; }
}
