:root {
  --ink: #121212;
  --paper: #f5f0e5;
  --signal: #ff3b18;
  --acid: #d9ff43;
  --panel: #d7d2c8;
  --page-width: 720px;
  --page-height: 960px;
  --page-ratio: 9 / 12;
  --gap: 12px;
  --row-gap: 5px;
  --grid-unit: 6px;
  --text-scale: 1;
  --shell-width: 1450px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, transparent 49.8%, rgba(18,18,18,.06) 50%, transparent 50.2%),
    #c9c5bc;
  font-family: "IBM Plex Mono", monospace;
}

button, input { font: inherit; }
button { cursor: pointer; }

.masthead {
  min-height: 230px;
  padding: 28px 32px 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  background: var(--acid);
  border-bottom: 2px solid var(--ink);
}

.eyebrow, .project-meta { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.maker-mark {
  color: var(--signal);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .12em;
  text-decoration: none;
  text-transform: uppercase;
}
.maker-mark:hover,
.maker-mark:focus-visible { color: var(--ink); }
.maker-mark + .eyebrow { margin: 8px 0 0; }

h1 {
  margin: 8px 0 0;
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(52px, 9vw, 124px);
  line-height: .74;
  letter-spacing: -.08em;
}

.project-meta {
  display: flex;
  align-items: flex-end;
  gap: 18px;
}

.project-counts {
  padding-bottom: 4px;
  display: grid;
  justify-items: end;
  gap: 7px;
}

.masthead-benjamin {
  width: 192px;
  aspect-ratio: 1;
  overflow: hidden;
  border: 12px solid var(--signal);
  border-radius: 50%;
  background: white;
}

.masthead-benjamin img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: 50% 30%;
  filter: contrast(1.12);
}

button {
  min-height: 38px;
  padding: 8px 12px;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--ink);
}

button:hover, button:focus-visible { background: var(--ink); color: var(--paper); }
button:disabled {
  color: #8d8980;
  background: #dedbd3;
  border-color: #aaa69d;
  cursor: not-allowed;
}
button:disabled:hover { color: #8d8980; background: #dedbd3; }
.primary { background: var(--signal); color: white; }

.controls {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  width: min(var(--shell-width), calc(100vw - 48px));
  margin: 0 auto;
  grid-template-columns: minmax(240px, 1fr) minmax(120px, .4fr) repeat(6, auto);
  gap: 16px;
  align-items: end;
  padding: 14px 22px;
  background: rgba(245,240,229,.94);
  border: 2px solid var(--ink);
  border-top-width: 1px;
  backdrop-filter: blur(10px);
}

.controls label { display: grid; gap: 6px; font-size: 10px; text-transform: uppercase; }
.controls label span { display: flex; justify-content: space-between; }
input[type="range"] { width: 100%; accent-color: var(--signal); }
.select-control select {
  min-height: 38px;
  padding: 6px 28px 6px 8px;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--ink);
}

.intro-stage,
main { padding: 30px 24px 0; }
.book-stage {
  padding-bottom: 100px;
  overflow-x: auto;
}

.site-footer {
  min-height: 92px;
  padding: 22px 32px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  color: var(--paper);
  background: var(--ink);
  border-top: 6px solid var(--signal);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.site-footer a {
  color: var(--acid);
  font-weight: 500;
  text-decoration: none;
}
.site-footer a:hover,
.site-footer a:focus-visible { color: white; }

.how-to-dialog {
  width: min(680px, calc(100vw - 32px));
  padding: 34px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 14px 14px 0 var(--signal);
}
.how-to-dialog::backdrop { background: rgba(18,18,18,.72); }
.tour-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  padding: 0;
  font-size: 22px;
}
.tour-count {
  margin: 0 0 24px;
  color: var(--signal);
  font-size: 10px;
  text-transform: uppercase;
}
.tour-content h2 {
  margin: 0 0 18px;
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(32px, 6vw, 58px);
  line-height: .92;
  letter-spacing: -.05em;
}
.tour-content p { max-width: 58ch; line-height: 1.6; }
.tour-content ul { padding-left: 20px; line-height: 1.65; }
.how-to-dialog nav {
  margin-top: 28px;
  display: flex;
  justify-content: space-between;
}

.empty-state {
  min-height: 0;
  width: min(var(--shell-width), calc(100vw - 48px));
  max-width: none;
  margin: 0 auto;
  padding: 30px 48px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 18px;
  align-content: center;
  justify-items: start;
  position: relative;
  overflow: hidden;
  background: var(--paper);
  border: 2px solid var(--ink);
}

.empty-state h2 {
  grid-column: 1 / -1;
  margin: 0;
  max-width: none;
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(42px, 4.5vw, 70px);
  line-height: .88;
  letter-spacing: -.065em;
  white-space: nowrap;
}

.empty-state p { max-width: none; line-height: 1.6; }
.intro-copy { grid-column: 1 / -1; margin: 12px 0 0; white-space: nowrap; }
.title-field {
  width: 100%;
  margin: 18px 0 14px;
}
.compiler-field {
  width: 100%;
  margin: 18px 0 14px;
}
.title-field input,
.compiler-field input {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1.5px solid var(--ink);
  font-size: 18px;
}
.title-field input::placeholder,
.compiler-field input::placeholder {
  color: #88847b;
  opacity: 1;
}
.folder-actions {
  grid-column: 1 / -1;
  width: 100%;
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 14px;
  align-items: center;
}
.folder-path {
  grid-column: 1 / -1;
  grid-row: 2;
  min-width: 0;
  padding: 0 4px;
  overflow: hidden;
  color: #6f6c65;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.compose-button {
  color: var(--ink);
  background: var(--acid);
}
.compose-button:hover,
.compose-button:focus-visible {
  color: white;
  background: var(--ink);
}
.folder-actions button:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.load-progress {
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 14px;
}
.load-progress div {
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  text-transform: uppercase;
}
.load-progress progress {
  width: 100%;
  height: 12px;
  display: block;
  appearance: none;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
}
.load-progress progress::-webkit-progress-bar { background: transparent; }
.load-progress progress::-webkit-progress-value { background: var(--signal); }
.load-progress progress::-moz-progress-bar { background: var(--signal); }

.book {
  display: grid;
  width: max-content;
  max-width: none;
  margin: 0 auto;
  grid-template-columns: repeat(2, minmax(0, var(--page-width))) !important;
  justify-content: start;
  gap: 42px 8px;
}

/* The front cover stands alone; the inside cover begins the first spread. */
.title-page {
  grid-column: 1 / -1;
  justify-self: center;
}

.page {
  container-type: inline-size;
  width: var(--page-width);
  height: auto;
  aspect-ratio: var(--page-ratio);
  padding: 28px;
  position: relative;
  overflow: hidden;
  background: white;
  box-shadow: 0 15px 40px rgba(0,0,0,.16);
}

.media-card {
  position: absolute;
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  overflow: hidden;
  background: #fffef9;
  border: 1px solid rgba(18, 18, 18, .78);
  cursor: grab;
}

.media-card.dragging { opacity: .25; }
.page.drag-target { outline: 5px solid var(--signal); outline-offset: -5px; }
.media-body { min-height: 0; flex: 1 1 auto; overflow: hidden; }
.media-body img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: left top; }
.media-body iframe { width: 100%; height: 100%; border: 0; pointer-events: none; }
.media-body pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: calc(11px * var(--text-scale))/1.35 "IBM Plex Mono", monospace;
}

.media-card footer {
  flex: 0 0 26px;
  min-height: 26px;
  padding-top: 5px;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  font-size: 8px;
  text-transform: uppercase;
  border: 0;
}

.filename { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-actions { display: flex; gap: 4px; }
.item-actions button {
  min-height: 16px;
  width: 18px;
  padding: 0;
  border: 0;
  font-weight: 500;
}
.shrink-button, .grow-button { background: rgba(18,18,18,.08); }
.hero-button {
  color: var(--ink);
  background: var(--acid);
  border-radius: 50%;
  font-size: 9px;
  transform: scale(.72);
}
.hero-button.is-hero {
  color: white;
  background: var(--ink);
}
.hero-button:disabled { opacity: .18; cursor: not-allowed; }
.crop-button {
  background: rgba(18,18,18,.08);
  border-radius: 50%;
}
.crop-button.is-active {
  color: white;
  background: var(--signal);
}
.crop-button[hidden] { display: none; }
.crop-editing {
  position: relative;
  cursor: move;
  touch-action: none;
  outline: 2px solid var(--signal);
  outline-offset: -2px;
}
.crop-controls {
  position: absolute;
  z-index: 3;
  top: 5px;
  right: 5px;
  display: flex;
  gap: 3px;
}
.crop-controls button {
  width: 24px;
  min-height: 24px;
  padding: 0;
  color: white;
  background: var(--ink);
  border: 0;
}
.explode-button {
  color: white;
  background: var(--ink);
  border-radius: 50%;
  font-size: 9px;
  transform: scale(.72);
}
.explode-button[hidden] { display: none; }
.type-shrink-button[hidden],
.type-grow-button[hidden],
.text-explode-button[hidden] { display: none; }
.type-shrink-button,
.type-grow-button,
.text-explode-button { background: rgba(217,255,67,.55); }
.exclude-button { background: var(--signal); border-radius: 50%; transform: scale(.55); }
.exclude-button:hover { background: #a51200; }
.is-monochrome .media-body { filter: grayscale(1) contrast(1.05); }

.page-footer {
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: 18px;
  height: 28px;
  padding-top: 8px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  border-top: 1px solid #c8c8c8;
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.folio { font-weight: 500; }
.folio-left { text-align: left; }
.folio-right { text-align: right; }

.title-hero {
  position: absolute;
  top: 28px;
  right: 28px;
  bottom: 70px;
  width: 44%;
  height: calc(100% - 98px);
  overflow: hidden;
  border: 1px solid var(--ink);
}
.title-hero img,
.inside-cover-hero img {
  width: 100%;
  height: 100%;
  display: block;
}
.title-page.has-hero .title-page-content {
  right: 50%;
}
.title-page.has-hero h2 { font-size: 58px; }

.title-page-content,
.technical-content {
  position: absolute;
  inset: 28px 28px 70px;
}

.title-page-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.title-page h2 {
  max-width: 92%;
  margin: 18px 0 24px;
  font-family: "Archivo Black", sans-serif;
  line-height: .88;
  letter-spacing: -.06em;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.title-kicker,
.folder-name {
  margin: 0;
  text-transform: uppercase;
}
.folder-name { font-size: 18px; }
.compiled-by {
  margin-top: 18px !important;
  font-size: 10px;
  text-transform: uppercase;
}

.inside-cover-hero {
  position: absolute;
  inset: 28px 28px 70px;
  width: calc(100% - 56px);
  height: calc(100% - 98px);
  overflow: hidden;
}
.inside-cover p {
  position: absolute;
  left: 28px;
  bottom: 24px;
  margin: 0;
  font-size: 8px;
  text-transform: uppercase;
}

.pdf-fallback {
  height: 100%;
  padding: 12px;
  display: grid;
  place-items: center;
  color: #6f6c65;
  border: 1px dashed #aaa69d;
  font-size: 9px;
  text-align: center;
  text-transform: uppercase;
}

.technical-content {
  display: grid;
  align-content: start;
  grid-template-columns: 1fr 1fr;
  gap: clamp(7px, 1.95cqw, 14px) clamp(12px, 3.33cqw, 24px);
}

.technical-signoff {
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: 28px;
  display: grid;
  gap: clamp(7px, 1.4cqw, 10px);
  justify-items: start;
}

.technical-content h2 {
  grid-column: 1 / -1;
  margin: 0;
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(18px, 5.56cqw, 40px);
  line-height: .92;
  letter-spacing: -.05em;
}

.technical-content p {
  margin: 0;
  font-size: clamp(4.5px, 1.3cqw, 10px);
  line-height: 1.45;
}
.technical-content dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: start;
}
.technical-content dt,
.technical-content dd {
  margin: 0;
  padding: clamp(3px, .83cqw, 6px) 0;
  border-top: 1px solid #ccc;
  font-size: clamp(4px, 1.25cqw, 9px);
}
.technical-content dd { text-align: right; }
.technical-privacy {
  grid-column: 1 / -1;
  padding: clamp(7px, 1.4cqw, 10px);
  border: 1px solid var(--ink);
  font-weight: 500;
}
.technical-code {
  grid-column: 1 / -1;
  margin: 0;
}
.technical-code figcaption {
  margin-bottom: clamp(4px, .8cqw, 6px);
  font-size: clamp(4px, 1.1cqw, 8px);
  font-weight: 500;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.technical-code pre {
  margin: 0;
  padding: clamp(4px, 1.4cqw, 10px);
  overflow: hidden;
  color: var(--paper);
  background: var(--ink);
  font: clamp(3.5px, 1.1cqw, 8px)/1.45 "IBM Plex Mono", monospace;
  white-space: pre-wrap;
}
.folio-url {
  margin: 0;
  font-size: clamp(4.5px, 1.39cqw, 10px);
  font-weight: 500;
  text-transform: uppercase;
}
.production-tag {
  margin: 0;
  padding: 9px 12px;
  justify-self: start;
  color: white;
  background: var(--ink);
  font-size: clamp(4.5px, 1.25cqw, 9px);
  text-transform: uppercase;
}
.brand-marks {
  display: flex;
  align-items: flex-end;
  gap: clamp(12px, 3.33cqw, 24px);
}
.brand-mark {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
}
.brand-mark img,
.brand-mark canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
.brand-logo {
  width: clamp(7px, 2.03cqw, 15px);
  aspect-ratio: 280 / 2155;
}
.brand-logo img {
  object-position: left bottom;
}
.brand-chopper {
  width: clamp(70px, 25cqw, 180px);
  aspect-ratio: 1280 / 772;
}
.brand-chopper img {
  object-position: left bottom;
}

@media (max-width: 1500px) {
  :root {
    --page-width: 540px;
    --grid-unit: 4px;
    --row-gap: 4px;
  }
  .page { padding: 25px; }
}

@media (max-width: 1120px) {
  .controls { grid-template-columns: repeat(4, 1fr); }
  :root { --page-width: calc((100vw - 58px) / 2); }
  .book { grid-template-columns: repeat(2, minmax(0, var(--page-width))) !important; }
  .masthead-benjamin { width: 140px; border-width: 9px; }
}

@media (max-width: 650px) {
  :root {
    --page-width: calc(100vw - 24px);
    --grid-unit: 2px;
    --row-gap: 3px;
  }
  .masthead { min-height: 180px; padding: 20px 16px; }
  .controls { position: static; grid-template-columns: repeat(2, 1fr); }
  .book { grid-template-columns: repeat(2, minmax(0, var(--page-width))) !important; }
  main { padding: 22px 0 60px; }
  .empty-state { margin: 0 12px; padding: 28px; }
  .empty-state { width: auto; min-height: 480px; }
  .empty-state { grid-template-columns: 1fr; }
  .title-field,
  .compiler-field { grid-column: 1 / -1; margin-bottom: 0; }
  .compiler-field { margin-top: 0; margin-bottom: 14px; }
  .folder-actions { grid-template-columns: 1fr; }
  .folder-path { padding: 4px 0; }
  .empty-state h2,
  .intro-copy { white-space: normal; }
  .project-counts { display: none; }
  .masthead-benjamin { width: 82px; border-width: 7px; }
  .page { padding: 18px; column-gap: 10px; }
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
}

@page {
  size: 9in 12in;
  margin: 0;
}

@media print {
  body { background: white; }
  .masthead, .controls, .empty-state, .site-footer { display: none !important; }
  main { padding: 0; }
  .book { display: block; }
  .page {
    width: 9in;
    height: 12in;
    margin: 0;
    padding: 0;
    box-shadow: none;
    break-after: page;
  }
  .item-actions button:not(.exclude-button) { display: none; }
  .exclude-button {
    display: block;
    background: white;
    border: 1px solid var(--ink) !important;
    transform: scale(.62);
  }
  .crop-controls { display: none !important; }
  .crop-editing { outline: 0; }
}

.pdf-exporting {
  --page-width: 720px;
}

.pdf-exporting .masthead,
.pdf-exporting .controls,
.pdf-exporting .empty-state,
.pdf-exporting .site-footer {
  display: none !important;
}

.pdf-exporting .item-actions button:not(.exclude-button) {
  display: none;
}

.pdf-exporting .exclude-button {
  display: block;
  background: white;
  border: 1px solid var(--ink) !important;
  transform: scale(.62);
}
.pdf-exporting .crop-controls { display: none !important; }
.pdf-exporting .crop-editing { outline: 0; }
