:root {
  /* Near-black on near-white: the dichotomy */
  --ink: #141414;
  --ink-soft: #555550;
  --paper: #fbfbf9;
  --line: #141414;

  --split-duration: 1600ms;
  --split-ease: cubic-bezier(0.65, 0, 0.15, 1);

  /* Everything below is overridden live by script.js from the config */
  --cut-top: 100%;
  --cut-bottom: 0%;

  --type-size: 15px;
  --type-tracking: 0.2em;

  --identity-x: 8%;
  --identity-y: 12%;
  --contact-x: 68%;
  --contact-y: 34%;
}

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

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: "Zen Kaku Gothic New", "Hiragino Sans", sans-serif;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}

/* Side bars: fade in on the same clock as the revealed page */
.bar {
  position: fixed;
  top: 0;
  bottom: 0;
  width: var(--bar-width, 0);
  background: var(--bar);
  opacity: 0;
  transition: opacity 900ms ease 700ms;
}

.bar-left { left: 0; }
.bar-right { right: 0; }

body.open .bar { opacity: 1; }
body.editing .bar { opacity: 1; transition: none; }

/* ---------- Landing curtain ---------- */

.curtain {
  position: fixed;
  inset: 0;
  cursor: pointer;
  z-index: 10;
  outline: none;
}

.shard {
  position: absolute;
  inset: 0;
  overflow: hidden;
  transition:
    transform var(--split-duration) var(--split-ease),
    opacity var(--fade-duration, 1100ms) ease var(--fade-delay, 300ms);
  will-change: transform, opacity;
  background: #1c1e1a;
}

.shard img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.shard-left  { clip-path: polygon(0 0, var(--cut-top) 0, var(--cut-bottom) 100%, 0 100%); }
.shard-right { clip-path: polygon(var(--cut-top) 0, 100% 0, 100% 100%, var(--cut-bottom) 100%); }

body.open .shard-left  { transform: translateX(-115%); }
body.open .shard-right { transform: translateX(115%); }
body.open.fade .shard  { opacity: 0; }
body.open .curtain { pointer-events: none; }

/* ---------- Information page ---------- */

.reveal {
  position: fixed;
  inset: 0;
  left: var(--bar-width, 0);
  right: var(--bar-width, 0);
  overflow: hidden;
  background: var(--paper);
}

.reveal > * {
  opacity: 0;
  transition: opacity 900ms ease 700ms;
}

body.open .reveal > * { opacity: 1; }

/* The three sketch lines */
.lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.lines line {
  stroke: var(--line);
  stroke-width: 1px;
}

/* Portrait clipped to the bottom triangle (clip-path set from config by JS) */
.portrait {
  position: absolute;
  inset: 0;
}

.portrait img {
  position: absolute;
  height: auto;
  display: block;
  filter: grayscale(1) contrast(1.02);
}

/* ---------- Text blocks ---------- */

/* Every line of text: one element, absolutely positioned,
   styled per-line from the config. */
.txt {
  position: absolute;
  color: var(--ink);
  text-transform: uppercase;
  text-decoration: none;
  white-space: pre; /* honors the line breaks typed in edit mode */
  line-height: 1.4;
  width: fit-content;
}

a.txt {
  padding-bottom: 0.25em;
  border-bottom: 1px solid transparent;
  transition: border-color 300ms ease;
}

a.txt:hover,
a.txt:focus-visible {
  border-color: var(--ink);
}

/* ---------- Edit mode ---------- */

body.editing:not(.replaying) .curtain { display: none; }
body.replaying .curtain { pointer-events: none; }

/* Mobile editing stage: the page becomes a phone-sized frame */
body.stage-mobile { background: #c9c7c0; }
body.stage-mobile .reveal {
  inset: auto;
  left: calc((100vw - 250px - 24px) / 2); /* centered in the space left of the panel */
  top: 50%;
  transform: translate(-50%, -50%);
  width: 390px;
  height: min(800px, calc(100vh - 32px));
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35), 0 18px 50px rgba(0,0,0,0.3);
}
body.editing .reveal > * { opacity: 1; transition: none; }

body.editing .txt {
  cursor: grab;
  outline: 1px dashed rgba(20, 20, 20, 0.18);
  outline-offset: 6px;
}

body.editing .txt.selected {
  outline: 1.5px solid #2563eb;
  outline-offset: 6px;
}

.edit-panel {
  position: fixed;
  right: 12px;
  top: 12px;
  z-index: 100;
  width: 250px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #d6d6d0;
  padding: 14px;
  font-size: 11px;
  line-height: 1.4;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.edit-panel h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 10px 0 4px;
  font-weight: 500;
}

.edit-panel h2:first-child { margin-top: 0; }

.edit-panel label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin: 2px 0;
}

.edit-panel input[type="range"] { width: 130px; }
.edit-panel select { font: inherit; max-width: 150px; }
.edit-panel output { width: 34px; text-align: right; }

.edit-panel .buttons {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.edit-panel button {
  flex: 1;
  padding: 5px 0;
  font: inherit;
  background: #141414;
  color: #fff;
  border: 0;
  cursor: pointer;
}

.edit-panel button.secondary {
  background: #fff;
  color: #141414;
  border: 1px solid #141414;
}

.edit-panel .fmt button {
  background: #fff;
  color: #141414;
  border: 1px solid #bbb;
  min-width: 26px;
}

.edit-panel .fmt button.active {
  background: #141414;
  color: #fff;
  border-color: #141414;
}

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  .shard { transition-duration: 1ms; }
  .reveal > * { transition-delay: 0ms; transition-duration: 1ms; }
}
