@import './brand/tokens.css';
@import './brand/motion.css';
@import './brand/wordmark.css';

:root {
  --pulp-background: var(--pulp-color-semantic-background);
  --pulp-surface: var(--pulp-color-semantic-surface);
  --pulp-foreground: var(--pulp-color-semantic-foreground);
  --pulp-muted: var(--pulp-color-semantic-muted);
  --pulp-teal: var(--pulp-color-semantic-structural);
  --pulp-accent: var(--pulp-color-semantic-accent);
  --pulp-glow: var(--pulp-color-semantic-glow);
  --pulp-metal: var(--pulp-color-semantic-metal);
  --pulp-hairline: var(--pulp-color-semantic-hairline);
  --pulp-ghost: var(--pulp-color-semantic-ghost);
}

body {
  --pulp-teal: color-mix(
    in srgb,
    var(--pulp-color-semantic-structural) 78%,
    var(--pulp-material-structural, var(--pulp-color-semantic-structural))
  );
  --pulp-accent: color-mix(
    in srgb,
    var(--pulp-color-semantic-accent) 82%,
    var(--pulp-material-accent, var(--pulp-color-semantic-accent))
  );
  --pulp-glow: color-mix(
    in srgb,
    var(--pulp-color-semantic-glow) 82%,
    var(--pulp-material-glow, var(--pulp-color-semantic-glow))
  );
  --pulp-metal: color-mix(
    in srgb,
    var(--pulp-color-semantic-metal) 82%,
    var(--pulp-material-metal, var(--pulp-color-semantic-metal))
  );
}

:root {
  --shadow: 0 24px 80px rgb(0 0 0 / 35%);
  font-family:
    Inter,
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
}
* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--pulp-background);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--pulp-foreground);
  background:
    radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--pulp-accent) 9%, transparent), transparent 24rem),
    radial-gradient(circle at 85% 20%, color-mix(in srgb, var(--pulp-teal) 8%, transparent), transparent 28rem),
    linear-gradient(
      155deg,
      var(--pulp-surface) 0%,
      var(--pulp-background) 52%,
      color-mix(in srgb, var(--pulp-background) 92%, black) 100%
    );
}

button,
select,
a {
  font: inherit;
}

button,
select {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
pre:focus-visible {
  outline: 2px solid var(--pulp-accent);
  outline-offset: 4px;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 20;
  opacity: 0.055;
  pointer-events: none;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.75'/%3E%3C/svg%3E");
}

.masthead,
.footer {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem clamp(1rem, 3vw, 3rem);
}

.masthead {
  min-height: 5.25rem;
  border-bottom: 1px solid var(--pulp-ghost);
  backdrop-filter: blur(18px);
}

.identity {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  color: inherit;
  text-decoration: none;
}

.identity-mark {
  display: grid;
  width: 2.3rem;
  height: 2.3rem;
  place-items: center;
  border: 1px solid var(--pulp-hairline);
  border-radius: 50%;
  color: var(--pulp-accent);
  font-family: Georgia, serif;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.identity strong,
.identity small {
  display: block;
}

.identity strong {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.identity small {
  margin-top: 0.18rem;
  color: var(--pulp-muted);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.masthead-actions {
  display: flex;
  align-items: end;
  gap: 0.75rem;
}

.appearance-control,
.lane-control {
  display: grid;
  gap: 0.3rem;
}

.appearance-control span,
.lane-control span {
  color: var(--pulp-muted);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

select,
.quiet-button {
  border: 1px solid var(--pulp-hairline);
  border-radius: 999px;
  background: color-mix(in srgb, var(--pulp-background) 55%, transparent);
}

select {
  min-width: 11rem;
  padding: 0.6rem 2rem 0.6rem 0.85rem;
}

.quiet-button {
  padding: 0.62rem 0.9rem;
  cursor: pointer;
}

.encounter {
  position: relative;
  z-index: 5;
  width: min(1180px, calc(100% - 2rem));
  min-height: calc(100vh - 10rem);
  margin: 0 auto;
  padding: clamp(2.2rem, 6vh, 6rem) 0 4rem;
}

.opening {
  max-width: 860px;
}

.eyebrow,
.kicker {
  margin: 0 0 0.9rem;
  color: var(--pulp-accent);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.opening h1 {
  max-width: 13ch;
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(3rem, 8vw, 7.8rem);
  font-weight: 400;
  line-height: 0.9;
  letter-spacing: -0.055em;
  text-wrap: balance;
  text-shadow: 0 0 48px rgba(227, 170, 91, 0.08);
}

.lede {
  max-width: 700px;
  margin: 1.5rem 0 0;
  color: var(--pulp-muted);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(1.05rem, 2vw, 1.45rem);
  line-height: 1.55;
}

.mode-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 2rem;
}

.mode {
  padding: 0.65rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--pulp-muted);
  background: transparent;
  cursor: pointer;
}

.mode:hover,
.mode.active {
  border-color: var(--pulp-hairline);
  color: var(--pulp-foreground);
  background: var(--pulp-ghost);
}

.stage {
  position: relative;
  margin-top: clamp(2.5rem, 7vh, 6.5rem);
}

.view {
  display: none;
  animation: reveal 500ms ease both;
}

.view.active {
  display: block;
}

#drift-view {
  max-width: 760px;
  min-height: 19rem;
  padding: clamp(1.4rem, 4vw, 3rem);
  border: 1px solid var(--pulp-hairline);
  border-radius: 2rem;
  background: linear-gradient(145deg, rgba(23, 19, 26, 0.82), rgba(10, 9, 12, 0.48));
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.drift-copy h2,
.edition-intro h2,
.manifest-layout h2,
.thread-detail h2 {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 400;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.drift-copy h2 {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.02;
}

.drift-copy p:last-child,
.thread-detail > p,
.manifest-layout header > p:last-child {
  color: var(--pulp-muted);
  line-height: 1.65;
}

.primary-action,
.text-action {
  border: 0;
  cursor: pointer;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1.5rem;
  padding: 0.85rem 1.1rem;
  border-radius: 999px;
  color: var(--pulp-color-semantic-onaccent);
  background: var(--pulp-accent);
  font-weight: 700;
  text-decoration: none;
}

.primary-action::after {
  content: '↗';
  margin-left: 0.55rem;
}

.thread-layout {
  display: grid;
  grid-template-columns: minmax(15rem, 0.7fr) minmax(0, 1.5fr);
  gap: clamp(1rem, 4vw, 4rem);
}

.thread-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--pulp-hairline);
}

.thread-list button {
  width: 100%;
  padding: 1rem 0.2rem;
  border: 0;
  border-bottom: 1px solid var(--pulp-hairline);
  color: var(--pulp-muted);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.thread-list button:hover,
.thread-list button.active {
  color: var(--pulp-foreground);
}

.thread-list button span {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--pulp-accent);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.thread-detail {
  min-height: 20rem;
  padding: clamp(1.5rem, 4vw, 3rem);
  border: 1px solid var(--pulp-hairline);
  border-radius: 2rem;
  background: var(--pulp-surface);
  backdrop-filter: blur(20px);
}

.thread-detail h2 {
  max-width: 15ch;
  font-size: clamp(2.2rem, 5vw, 4.6rem);
  line-height: 0.98;
}

.relation-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1.4rem;
}

.relation-row span {
  padding: 0.4rem 0.62rem;
  border: 1px solid var(--pulp-hairline);
  border-radius: 999px;
  color: var(--pulp-muted);
  font-size: 0.72rem;
}

.text-action {
  margin-top: 1.5rem;
  padding: 0;
  border-bottom: 1px solid var(--pulp-accent);
  color: var(--pulp-accent);
  background: transparent;
}

.edition-intro {
  max-width: 760px;
}

.edition-intro h2,
.manifest-layout h2 {
  font-size: clamp(2.3rem, 5.5vw, 5rem);
  line-height: 0.98;
}

.edition-stack {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 2rem;
}

.edition-layer {
  min-height: 20rem;
  padding: 1.25rem;
  border: 1px solid var(--pulp-hairline);
  border-radius: 1.4rem;
  background: rgba(13, 11, 15, 0.72);
  backdrop-filter: blur(18px);
}

.edition-layer span,
.edition-layer small {
  color: var(--pulp-muted);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.edition-layer h3 {
  margin: 3rem 0 0.8rem;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.55rem;
  font-weight: 400;
  line-height: 1.08;
}

.edition-layer p {
  min-height: 7rem;
  color: var(--pulp-muted);
  line-height: 1.55;
}

.edition-layer[data-kind='evidence'] {
  border-top-color: var(--pulp-teal);
}

.edition-layer[data-kind='claim'] {
  border-top-color: var(--pulp-accent);
}

.edition-layer[data-kind='interpretation'] {
  border-top-color: var(--pulp-metal);
}

.edition-layer[data-kind='projection'] {
  border-top-color: var(--pulp-accent);
}

.manifest-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: clamp(1.5rem, 5vw, 5rem);
  align-items: start;
}

.manifest-layout pre {
  max-height: 28rem;
  margin: 0;
  padding: 1.25rem;
  overflow: auto;
  border: 1px solid var(--pulp-hairline);
  border-radius: 1.4rem;
  color: var(--pulp-color-semantic-foreground);
  background: color-mix(in srgb, var(--pulp-color-semantic-surfaceinset) 92%, transparent);
  font:
    0.78rem/1.6 ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
  box-shadow: var(--shadow);
}

.link-action {
  grid-column: 2;
  justify-self: start;
  margin-top: -3.7rem;
}

.provenance-panel {
  position: fixed;
  z-index: 30;
  top: 0;
  right: 0;
  width: min(34rem, 100%);
  height: 100vh;
  padding: 1.2rem;
  overflow: auto;
  border-left: 1px solid var(--pulp-hairline);
  background: rgba(8, 7, 10, 0.96);
  box-shadow: -30px 0 90px rgba(0, 0, 0, 0.45);
  transform: translateX(102%);
  transition: transform 300ms ease;
}

.provenance-panel.open {
  transform: translateX(0);
}

.panel-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--pulp-hairline);
  color: var(--pulp-muted);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.provenance-panel dl {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0.8rem 1rem;
  margin-top: 2rem;
}

.provenance-panel dt {
  color: var(--pulp-muted);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.provenance-panel dd {
  margin: 0;
  line-height: 1.5;
}

.footer {
  min-height: 4.5rem;
  border-top: 1px solid var(--pulp-ghost);
  color: var(--pulp-muted);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

.footer p {
  margin: 0;
}

.footer strong {
  color: var(--pulp-foreground);
  font-weight: 500;
}

.noscript {
  position: fixed;
  inset: auto 1rem 1rem;
  z-index: 40;
  padding: 1rem;
  border: 1px solid var(--pulp-hairline);
  background: var(--pulp-background);
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .edition-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .manifest-layout {
    grid-template-columns: 1fr;
  }

  .link-action {
    grid-column: auto;
    margin-top: 0;
  }
}

@media (max-width: 700px) {
  .footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .encounter {
    min-height: auto;
    padding-top: 1.4rem;
  }

  .opening h1 {
    font-size: clamp(3.2rem, 18vw, 5rem);
  }

  .thread-layout,
  .edition-stack {
    grid-template-columns: 1fr;
  }

  .edition-layer {
    min-height: 14rem;
  }

  .edition-layer h3 {
    margin-top: 1.8rem;
  }

  .edition-layer p {
    min-height: auto;
  }

  .provenance-panel dl {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.masthead-menu-toggle {
  display: none;
  min-width: 4.5rem;
  min-height: 2.75rem;
  padding: 0.55rem 0.85rem;
  color: var(--pulp-foreground);
  font: 600 0.68rem/1 var(--pulp-type-mono);
  letter-spacing: 0.11em;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--pulp-surface) 82%, transparent);
  border: 1px solid var(--pulp-hairline);
  border-radius: 999px;
  cursor: pointer;
}

@media (max-width: 700px) {
  .masthead {
    position: relative;
    min-height: 4.5rem;
    align-items: center;
    flex-direction: row;
    padding-block: 0.7rem;
  }

  .masthead-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-inline-start: auto;
  }

  .masthead-actions {
    position: absolute;
    z-index: 30;
    inset-block-start: calc(100% - 1px);
    inset-inline: 0;
    display: none;
    grid-template-columns: 1fr;
    gap: 0.8rem;
    width: auto;
    max-height: min(34rem, calc(100vh - 5.5rem));
    padding: 1rem;
    overflow: auto;
    color: var(--pulp-foreground);
    background: var(--pulp-surface);
    border-block: 1px solid var(--pulp-hairline);
    box-shadow: 0 22px 60px rgb(0 0 0 / 34%);
    backdrop-filter: none;
  }

  .masthead[data-menu-open='true'] .masthead-actions {
    display: grid;
  }

  .masthead[data-menu-open='true'] .masthead-menu-toggle {
    color: var(--pulp-color-semantic-oninteractive);
    background: var(--pulp-color-semantic-interactive);
    border-color: var(--pulp-color-semantic-interactive);
  }

  .appearance-control,
  .lane-control {
    gap: 0.45rem;
  }

  .appearance-control span,
  .lane-control span {
    display: block;
  }

  .material-control {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
    padding: 0;
    border: 0;
    border-radius: 0;
  }

  .material-control button,
  .quiet-button,
  select {
    width: 100%;
    min-height: 2.75rem;
  }

  .material-control button {
    justify-content: flex-start;
    padding-inline: 0.8rem;
    border: 1px solid var(--pulp-hairline);
    border-radius: 999px;
  }

  .identity {
    gap: 0.55rem;
    min-width: 0;
  }

  .identity-meta {
    display: grid;
    gap: 0.08rem;
    min-width: 5.6rem;
  }

  .identity-meta strong {
    font-size: 0.58rem;
    line-height: 1.05;
  }

  .identity-meta small {
    max-width: 6rem;
    font-size: 0.5rem;
    line-height: 1.08;
    letter-spacing: 0.09em;
    text-transform: uppercase;
  }

  .pulp-wordmark {
    width: 4.9rem;
  }

  .masthead-menu-toggle {
    min-width: 4.15rem;
    padding-inline: 0.72rem;
  }

  .encounter {
    padding-top: 1.4rem;
  }
}
