/* ==========================================================================
   rotten.sh
   ========================================================================== */

/* ---- fonts: swap families here (loaded in each page's <head>) ---------- */
:root {
  --font-serif: "Noto Serif JP", "Times New Roman", Times, serif;
  --font-mono:  "IBM Plex Mono", "Courier New", monospace;
  --font-term:  "VT323", "Courier New", monospace;
  --font-label: "Share Tech Mono", "Courier New", monospace;

  --ink:    #b9bcc0;   /* main text      */
  --bright: #e2e4e8;   /* titles / hover */
  --dim:    #7c8086;   /* secondary      */
  --faint:  #474a4f;   /* tertiary       */
  --line:   #8e9298;   /* dividers       */
  --panel:  #000;

  --panel-w: 640px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

/* old pixel cursors (made by tools/make-cursors.js) */
html, body { cursor: url("../img/cursor.svg") 0 0, default; }
a, button, label, .bare, .gate-enter, .button88, [data-troll] {
  cursor: url("../img/cursor-link.svg") 4 0, pointer;
}
input, textarea { cursor: text; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 13px;
  line-height: 1.7;
  /* 1px scanline wall, like an old CRT left on */
  background-color: #121315;
  background-image: repeating-linear-gradient(
    0deg,
    #0a0b0c 0 1px,
    #2c2e32 1px 2px,
    #18191c 2px 3px
  );
  overflow-x: hidden;
}

a { color: var(--ink); text-decoration: none; }
a:hover, a:focus-visible { color: var(--bright); text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible { outline: 1px dotted var(--dim); outline-offset: 3px; }

::selection { background: var(--bright); color: #000; }

/* ---- panels: floating black boxes -------------------------------------- */
.panel {
  position: relative;
  width: min(var(--panel-w), calc(100% - 28px));
  margin: 34px auto;
  padding: 30px 28px 26px;
  background: var(--panel);
  box-shadow: 0 0 0 1px #000, 7px 9px 16px rgba(0, 0, 0, 0.75);
  text-align: center;
}
.panel + .panel { margin-top: 46px; }

/* corner brackets  ⌈  ⌉  /  ⌊  ⌋ */
.brackets {
  display: flex; justify-content: space-between;
  width: 62%; margin: 0 auto;
  font-family: var(--font-serif); color: var(--dim);
  font-size: 14px; line-height: 1;
  user-select: none;
}

/* ---- the title ---------------------------------------------------------- */
.site-title {
  margin: 10px 0 0;
  font-weight: 400;
  font-size: 17px;
  line-height: 1.55;
  letter-spacing: 0.55em;
  color: var(--bright);
  white-space: pre;           /* deliberately uneven line breaks */
}
.site-title a { color: inherit; }
.site-title a:hover { text-decoration: none; }
.site-title .sub {
  display: block;
  font-family: var(--font-label);
  font-size: 9px; letter-spacing: 0.9em;
  color: var(--faint);
  margin-top: 8px;
}

.glyphs {
  margin: 26px 0 4px;
  font-family: var(--font-mono);
  font-size: 15px; letter-spacing: 0.08em;
  color: var(--dim);
  user-select: none;
}

.tiny {
  font-size: 9px;
  letter-spacing: 0.55em;
  line-height: 1.6;
  color: var(--dim);
}
.label {
  font-family: var(--font-label);
  font-size: 10px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--dim);
}
.term { font-family: var(--font-term); font-size: 18px; letter-spacing: 0.08em; }
.jp   { font-family: var(--font-serif); letter-spacing: 0.3em; }

/* text buttons that look like nothing: [ like this ] */
.bare {
  background: none; border: 0; padding: 0;
  font: inherit; color: var(--ink); letter-spacing: inherit;
  cursor: pointer;
}
.bare:hover, .bare:focus-visible { color: var(--bright); text-decoration: underline; text-underline-offset: 3px; }
.bare:focus-visible { outline: 1px dotted var(--dim); outline-offset: 3px; }

/* ---- navigation --------------------------------------------------------- */
.nav {
  margin: 30px 0 0;
  font-size: 11px;
  letter-spacing: 0.42em;
  line-height: 2;
}
.nav a { color: var(--dim); }
.nav a:hover { color: var(--bright); }
.nav a[aria-current="page"] { color: var(--bright); }
.nav a[aria-current="page"]::before { content: "›"; letter-spacing: 0.2em; }
.nav .sep { color: var(--faint); padding: 0 0.25em 0 0; user-select: none; }

/* full-bleed divider inside a panel */
.rule {
  height: 0; border: 0;
  border-top: 2px solid var(--line);
  margin: 22px -28px;
}

.status { margin-top: 4px; font-size: 12px; letter-spacing: 0.42em; }
.status .blink { animation: blink 1.6s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---- posts / log entries ----------------------------------------------- */
.post .mark { color: var(--dim); font-size: 13px; margin-bottom: 4px; user-select: none; }
.post h2 {
  margin: 0;
  font-weight: 400; font-size: 14px;
  letter-spacing: 0.42em;
  color: var(--bright);
}
.post .by   { font-size: 10px; letter-spacing: 0.5em; color: var(--dim); margin-top: 2px; }
.post .date { font-family: var(--font-label); font-size: 9px; letter-spacing: 0.5em; color: var(--faint); }
.post .body {
  font-size: 11px;
  letter-spacing: 0.3em;
  line-height: 1.95;
  text-align: center;
}
.post .body p { margin: 0 0 1.4em; }
.post .body p:last-child { margin-bottom: 0; }
.post .body .jp { letter-spacing: 0.35em; }
.post .more { display: inline-block; margin-top: 14px; font-size: 10px; letter-spacing: 0.5em; }

/* small dithered picture inside a post */
.post .pic {
  display: block; margin: 0 auto 18px; max-width: 100%;
  filter: grayscale(1) contrast(1.4) brightness(0.85);
  image-rendering: pixelated;
}

/* ---- footer ------------------------------------------------------------- */
.footer {
  margin: 40px auto 46px;
  text-align: center;
  font-size: 9px; letter-spacing: 0.55em; line-height: 2.1;
  color: var(--faint);
  text-shadow: 0 0 4px #000, 0 0 2px #000;
}
.footer a { color: var(--dim); }

/* ==========================================================================
   homepage figure
   ========================================================================== */
.room {
  --H: min(84vh, 132vw, 900px);    /* figure height */
  --drop: min(10vh, 90px);         /* rope between beam and image */
  position: relative;
  height: calc(var(--drop) + var(--H) + 70px);
  margin: 0;
  overflow: hidden;
  /* the forest fades into the scanline wall at top and bottom */
  -webkit-mask-image: linear-gradient(transparent, #000 34px, #000 calc(100% - 50px), transparent);
          mask-image: linear-gradient(transparent, #000 34px, #000 calc(100% - 50px), transparent);
}
.room canvas   { position: absolute; display: block; image-rendering: pixelated; }
.room .forest  { left: 0; top: 0; z-index: 0; pointer-events: none; }
.room .weather { left: 0; top: 0; z-index: 3; pointer-events: none; }
.room .beam    { z-index: 2; pointer-events: none; }   /* rope knot on the branch, placed by figure.js */
/* mist settling on the floor */
.room::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 32%; z-index: 2;
  background: linear-gradient(transparent, rgba(12, 13, 15, 0.55) 70%, rgba(10, 10, 12, 0.8));
  pointer-events: none;
}
.room .swing {
  top: 60px;                        /* pivot = underside of the branch */
  z-index: 1;
  will-change: transform;
  filter: drop-shadow(-8px 6px 8px rgba(0, 0, 0, 0.75));   /* moon is up and to the right */
}
.room .swing.glitch { filter: url(#distort) drop-shadow(-8px 6px 8px rgba(0, 0, 0, 0.75)); }
.room .fallback {
  position: absolute; left: 50%; top: calc(60px + var(--drop));
  height: var(--H); transform: translateX(-50%);
  filter: grayscale(1) contrast(1.4) brightness(0.8);
}
.room .caption {
  position: absolute; right: max(14px, calc(50% - 330px)); bottom: 22px; z-index: 3;
  font-family: var(--font-label); font-size: 9px; letter-spacing: 0.5em;
  color: var(--dim); text-align: right; text-shadow: 0 0 3px #000;
  writing-mode: vertical-rl;
}

/* ==========================================================================
   overlays: grain, scanlines, flicker
   ========================================================================== */
#grain, #scan, #flick {
  position: fixed; inset: 0; pointer-events: none;
}
#grain {
  z-index: 50; width: 100%; height: 100%;
  opacity: 0.055; mix-blend-mode: screen;
  image-rendering: pixelated;
}
#scan {
  z-index: 51;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.22) 0 1px, transparent 1px 3px);
}
#scan::after {   /* faint vignette like a curved tube */
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0,0,0,0.55) 100%);
}
#flick { z-index: 52; background: #000; opacity: 0; }

/* enter screen (homepage) */
.gate {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: #000;
  cursor: url("../img/cursor-link.svg") 4 0, pointer;
  transition: opacity 1.8s ease;
}
.gate.gone { opacity: 0; pointer-events: none; }
.gate-inner { width: min(420px, 86vw); text-align: center; }
.gate .site-title { margin: 18px 0 30px; }
.gate-enter {
  font-family: var(--font-serif); font-size: 15px; letter-spacing: 0.5em;
  color: var(--bright);
  animation: gate-flicker 4.5s infinite;
}
.gate .tiny { margin: 30px 0 18px; color: var(--faint); }
@keyframes gate-flicker {
  0%, 17%, 21%, 63%, 65%, 100% { opacity: 1; }
  19%, 64% { opacity: 0.2; }
}
html.gated, html.gated body { overflow: hidden; }

/* sound control, fixed in the corner */
.sound {
  position: fixed; left: 12px; bottom: 10px; z-index: 60;
  font-family: var(--font-label); font-size: 10px; letter-spacing: 0.35em;
  color: var(--dim); text-shadow: 0 0 3px #000;
}

/* ==========================================================================
   inner pages
   ========================================================================== */
.panel.head { padding-bottom: 20px; }
.panel.head.home { margin-top: 22px; margin-bottom: 18px; padding-top: 22px; }
.panel.head.home .glyphs { margin: 12px 0 6px; font-size: 13px; }
.panel.head .site-title { font-size: 14px; }
.panel.head .nav { margin-top: 18px; }

.prose { text-align: left; font-size: 12px; letter-spacing: 0.12em; line-height: 2; }
.prose p { margin: 0 0 1.3em; }
.prose h3 {
  margin: 1.8em 0 0.6em; text-align: center;
  font-weight: 400; font-size: 11px; letter-spacing: 0.6em; color: var(--bright);
}
.prose dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.3em 1.6em; margin: 0; }
.prose dt { font-family: var(--font-label); font-size: 10px; letter-spacing: 0.3em; color: var(--dim); text-transform: uppercase; }
.prose dd { margin: 0; }

.linklist { list-style: none; margin: 0; padding: 0; font-size: 12px; letter-spacing: 0.32em; line-height: 2.3; }
.linklist li::before { content: "▹ "; color: var(--faint); }
.linklist .note { color: var(--faint); font-size: 10px; letter-spacing: 0.2em; }

.button88 {   /* 88x31 badge */
  display: inline-block; width: 88px; height: 31px; margin: 4px;
  border: 1px solid var(--dim); background: #000;
  font-family: var(--font-term); font-size: 15px; line-height: 29px; color: var(--ink);
  letter-spacing: 0.1em; text-align: center; vertical-align: middle;
}
.button88:hover { background: var(--bright); color: #000; text-decoration: none; }

/* guestbook */
.gb-form { display: grid; gap: 12px; text-align: left; font-family: var(--font-mono); font-size: 12px; }
.gb-form label { display: grid; gap: 4px; }
.gb-form input, .gb-form textarea {
  width: 100%;
  background: #000; color: var(--bright);
  border: 0; border-bottom: 1px solid var(--dim); border-radius: 0;
  padding: 4px 2px;
  font: inherit; letter-spacing: 0.1em;
}
.gb-form textarea { resize: vertical; min-height: 90px; border: 1px solid var(--faint); }
.gb-form input:focus, .gb-form textarea:focus { outline: none; border-color: var(--bright); }
.gb-form .row { text-align: center; margin-top: 4px; }
.gb-msg { min-height: 1.6em; font-size: 10px; letter-spacing: 0.4em; color: var(--dim); }
.gb-entries { text-align: left; }
.gb-entry { padding: 14px 0; border-top: 1px dotted var(--faint); }
.gb-entry:first-child { border-top: 0; }
.gb-entry .who { font-family: var(--font-label); font-size: 10px; letter-spacing: 0.35em; color: var(--dim); }
.gb-entry .what { margin-top: 6px; font-size: 12px; letter-spacing: 0.12em; white-space: pre-wrap; word-break: break-word; }

/* archive index */
.index { list-style: none; margin: 0; padding: 0; text-align: left; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.15em; }
.index li { display: flex; gap: 14px; padding: 3px 0; }
.index .d { color: var(--faint); flex: none; font-family: var(--font-label); }
.index li:hover .d { color: var(--dim); }

/* ---- secrets ------------------------------------------------------------ */

/* hidden text: same colour as the panel, shows up when you select it */
.whisper { color: #000; }
.footer .whisper { color: transparent; text-shadow: none; }
.whisper::selection { background: var(--bright); color: #000; }

/* the drawing on cloud.html: paper taped to the wall */
.drawing {
  position: relative;
  width: min(340px, 100%); margin: 26px auto 14px; padding: 12px;
  background: #d9d8d2;
  box-shadow: 4px 6px 14px rgba(0,0,0,0.7);
  transform: rotate(-1.6deg);
  filter: grayscale(1) contrast(1.05) brightness(0.82);
}
.drawing svg { display: block; width: 100%; height: auto; }
.drawing .tape {
  position: absolute; width: 62px; height: 18px;
  background: rgba(235, 235, 225, 0.55);
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}
.drawing .t1 { top: -8px; left: 18px; transform: rotate(-8deg); }
.drawing .t2 { top: -6px; right: 16px; transform: rotate(6deg); }

/* ---- old-style dialog (fake download, endless confirm) ------------------ */
.dlg-back {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}
.dlg {
  width: min(360px, calc(100% - 32px));
  background: #000;
  border: 1px solid var(--dim);
  box-shadow: 0 0 0 1px #000, 8px 10px 0 rgba(0,0,0,0.6);
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em;
  color: var(--ink);
}
.dlg-title {
  display: flex; justify-content: space-between;
  padding: 3px 8px;
  background: var(--line); color: #000;
  font-family: var(--font-label); font-size: 11px; letter-spacing: 0.25em;
}
.dlg-body { padding: 18px 16px 8px; line-height: 1.8; min-height: 60px; }
.dlg-btns { display: flex; justify-content: center; gap: 22px; padding: 6px 0 14px; }
.dlg-btns .bare { font-family: var(--font-mono); letter-spacing: 0.15em; }
.dlg-bar {
  height: 14px; margin: 12px 0 4px;
  border: 1px solid var(--dim);
  background: repeating-linear-gradient(90deg, transparent 0 9px, #000 9px 10px);
}
.dlg-bar span {
  display: block; height: 100%; width: 0;
  background: repeating-linear-gradient(90deg, var(--ink) 0 8px, transparent 8px 10px);
}
.dlg-small { font-size: 10px; color: var(--dim); }
.dlg.shake { animation: dlg-shake 0.35s steps(2) 2; }
@keyframes dlg-shake { 50% { transform: translate(3px, -2px); } }

/* 404 */
.nosignal { font-family: var(--font-term); font-size: 56px; letter-spacing: 0.25em; color: var(--bright); line-height: 1; margin: 18px 0 6px; }

/* ==========================================================================
   small screens
   ========================================================================== */
@media (max-width: 560px) {
  body { font-size: 12px; }
  .panel { padding: 24px 16px 20px; margin: 22px auto; }
  .rule { margin: 18px -16px; }
  .brackets { width: 80%; }
  .site-title { font-size: 14px; letter-spacing: 0.42em; }
  .nav { letter-spacing: 0.3em; font-size: 10px; }
  .post .body { letter-spacing: 0.18em; }
  .tiny { letter-spacing: 0.35em; }
  .room .caption { display: none; }
  .prose dl { grid-template-columns: 1fr; }
}

/* ==========================================================================
   reduced motion: keep the mood, drop the movement
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .status .blink, .gate-enter { animation: none; }
  .gate { transition: none; }
  #flick { display: none; }
}
