/* ============================================================
   rv — cinematic darkroom
   charcoal + sodium-amber safelight, film grain, mono readouts
   ============================================================ */
:root {
  --bg:        #0a0a0b;
  --ink:       #f3efe6;   /* warm off-white */
  --dim:       #8a857b;   /* muted warm grey */
  --amber:     #ffae3b;   /* sodium safelight accent */
  --amber-dim: #c2812a;
  --line:      rgba(243, 239, 230, 0.12);
  --disp: "Bricolage Grotesque", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--ink);
  font-family: var(--mono); overflow: hidden; }
::selection { background: var(--amber); color: #1a1206; }

a { color: inherit; text-decoration: none; }
kbd {
  font-family: var(--mono); font-size: 10px; line-height: 1;
  color: var(--ink); background: #1b1a17; border: 1px solid var(--line);
  border-bottom-color: rgba(0,0,0,.6); border-radius: 4px;
  padding: 3px 5px; min-width: 16px; text-align: center; display: inline-block;
}

/* ---------- atmosphere ---------- */
#vignette { position: fixed; inset: 0; z-index: 5; pointer-events: none;
  background:
    radial-gradient(120% 120% at 50% 40%, transparent 55%, rgba(0,0,0,.55) 100%); }
#grain { position: fixed; inset: -50%; z-index: 6; pointer-events: none; opacity: .045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 7s steps(6) infinite; }
@keyframes grain {
  0%{transform:translate(0,0)} 16%{transform:translate(-6%,4%)}
  33%{transform:translate(5%,-5%)} 50%{transform:translate(-4%,6%)}
  66%{transform:translate(6%,3%)} 83%{transform:translate(-5%,-4%)} 100%{transform:translate(0,0)} }

/* ---------- feed progress ---------- */
#progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 30;
  background: rgba(255,255,255,.05); }
#progress span { display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--amber-dim), var(--amber));
  box-shadow: 0 0 10px var(--amber); transition: width .35s var(--ease); }

/* ---------- post index bar ---------- */
#postbar { position: fixed; top: 2px; left: 0; right: 0; z-index: 17;
  display: flex; gap: 2px; justify-content: flex-start; align-items: center;
  padding: 5px 12px; overflow-x: auto; white-space: nowrap; scrollbar-width: none;
  font-family: var(--mono); font-size: 11px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
  transition: opacity .4s var(--ease); }
#postbar::-webkit-scrollbar { display: none; }
body.idle #postbar { opacity: 0; pointer-events: none; }
.pb { flex: 0 0 auto; padding: 2px 6px; border-radius: 5px; color: var(--dim);
  cursor: pointer; user-select: none; transition: color .12s, background .12s; }
.pb:hover { color: var(--ink); background: rgba(255,255,255,.08); }
.pb.on { color: #1a1206; background: var(--amber); font-weight: 700; }
.pb.dup { display: none; } /* perceptual-duplicate post */

/* ---------- stage ---------- */
#stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
#media { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
#media img, #media video, #media iframe {
  width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
#media iframe { border: 0; }

/* ---------- edge nav ---------- */
.edge { position: fixed; top: 25%; height: 50%; width: 6%; min-width: 44px; max-width: 90px; z-index: 20;
  border: 0; outline: none; -webkit-tap-highlight-color: transparent;
  background: transparent; cursor: pointer; display: flex; align-items: center;
  opacity: 0; pointer-events: none; /* shown only on mouse activity */
  transition: opacity .25s var(--ease), background .2s var(--ease); }
body.mouse .edge { opacity: 1; pointer-events: auto; }
.edge:focus, .edge:focus-visible { outline: none; }
.edge-left  { left: 0;  justify-content: flex-start; padding-left: 10px;
  background: linear-gradient(90deg, rgba(0,0,0,.35), transparent); }
.edge-right { right: 0; justify-content: flex-end;  padding-right: 10px;
  background: linear-gradient(270deg, rgba(0,0,0,.35), transparent); }
.edge .chev { font-family: var(--mono); font-size: 26px; color: var(--ink); opacity: 0;
  transform: translateX(8px); transition: opacity .2s var(--ease), transform .2s var(--ease);
  text-shadow: 0 0 12px #000; }
.edge-right .chev { transform: translateX(-8px); }
.edge:hover { background: linear-gradient(90deg, rgba(255,174,59,.10), transparent); }
.edge-right:hover { background: linear-gradient(270deg, rgba(255,174,59,.10), transparent); }
.edge:hover .chev { opacity: 1; transform: translateX(0); }

/* ---------- chrome (auto-hides when idle) ---------- */
#help, #nav, #info { transition: opacity .4s var(--ease), transform .4s var(--ease); z-index: 16; }
body.idle #help, body.idle #nav { opacity: 0; pointer-events: none; }
/* caption stays visible regardless of idle; toggled with 'h' */
body.hideinfo #info { opacity: 0; pointer-events: none; }

/* top-left legend */
#help { position: fixed; top: 36px; left: 16px; display: flex; gap: 12px; flex-wrap: wrap;
  align-items: center; opacity: .25; }
#help:hover { opacity: 1; }
#help .grp { display: inline-flex; align-items: center; gap: 4px; }
#help .grp i { font-style: normal; color: var(--dim); font-size: 10px;
  text-transform: uppercase; letter-spacing: .12em; margin-left: 2px; }

/* top-right open links */
#nav { position: fixed; top: 34px; right: 16px; display: flex; gap: 8px; }
#nav a { display: inline-flex; align-items: center; gap: 6px; font-size: 11px;
  text-transform: uppercase; letter-spacing: .14em; color: var(--dim);
  padding: 6px 10px; border: 1px solid transparent; border-radius: 6px;
  background: rgba(10,10,11,.5); backdrop-filter: blur(6px);
  transition: color .2s, border-color .2s, background .2s; }
#nav a:hover { color: var(--ink); border-color: var(--line); background: rgba(20,18,14,.7); }
#nav a:hover kbd { background: var(--amber); color: #1a1206; border-color: var(--amber); }

/* bottom caption */
#info { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  padding: 64px 18% 22px 24px; pointer-events: none; }
#info a, #info { pointer-events: none; }
#info a { pointer-events: auto; }
#counter { font-family: var(--mono); font-size: 11px; letter-spacing: .22em; color: var(--amber);
  text-transform: uppercase; margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
#counter::before { content: "●"; font-size: 7px; transform: translateY(-1px);
  animation: rec 2s steps(1) infinite; }
@keyframes rec { 50% { opacity: .25; } }
#title { font-family: var(--disp); font-weight: 600; font-size: clamp(18px, 2.4vw, 30px);
  line-height: 1.15; letter-spacing: -.01em; max-width: 70ch; max-height: 2.4em; overflow: hidden;
  text-shadow: 0 2px 18px rgba(0,0,0,.8); }
#meta { margin-top: 8px; display: flex; gap: 8px; align-items: center; font-size: 12px;
  letter-spacing: .04em; color: var(--dim); }
#meta a { color: var(--ink); border-bottom: 1px solid var(--line); padding-bottom: 1px; }
#meta a:hover { color: var(--amber); border-color: var(--amber); }
#meta #dot1 { color: var(--dim); }

/* ---------- spinner ---------- */
#spinner { position: fixed; z-index: 18; display: flex; flex-direction: column;
  align-items: center; gap: 14px; }
#spinner .ring { width: 46px; height: 46px; border-radius: 50%;
  border: 2px solid rgba(255,174,59,.18); border-top-color: var(--amber);
  animation: spin .9s linear infinite; box-shadow: 0 0 18px rgba(255,174,59,.25); }
#spinner .lbl { font-size: 10px; letter-spacing: .35em; text-transform: uppercase; color: var(--amber-dim); }
@keyframes spin { to { transform: rotate(360deg); } }

#error { position: fixed; z-index: 18; max-width: 70%; text-align: center;
  font-size: 13px; line-height: 1.5; color: var(--ink);
  background: rgba(20,12,8,.9); border: 1px solid var(--amber-dim); border-left: 3px solid var(--amber);
  padding: 16px 22px; border-radius: 8px; }

/* ---------- debug overlay ---------- */
#debug { position: fixed; top: 70px; left: 16px; z-index: 25; max-width: min(440px, 80vw);
  font-family: var(--mono); font-size: 11px; line-height: 1.5; color: var(--amber);
  white-space: pre-wrap; word-break: break-all;
  background: rgba(8,8,10,.82); border: 1px solid var(--line); border-left: 2px solid var(--amber);
  border-radius: 8px; padding: 10px 12px; backdrop-filter: blur(6px); pointer-events: none; }
#debug .live { color: var(--ink); }

/* ---------- landing ---------- */
#landing { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center;
  justify-content: center;
  background:
    radial-gradient(80% 60% at 50% 22%, rgba(255,174,59,.06), transparent 60%),
    radial-gradient(120% 120% at 50% 50%, #111014 0%, #0a0a0b 70%); }
.frame { width: min(560px, 92vw); padding: 44px clamp(24px,5vw,52px);
  border: 1px solid var(--line); border-radius: 16px;
  background: linear-gradient(180deg, rgba(24,22,18,.7), rgba(12,11,12,.6));
  backdrop-filter: blur(10px); box-shadow: 0 40px 120px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.04);
  animation: rise .6s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.frame > * { animation: rise .6s var(--ease) both; }
.frame > .brand  { animation-delay: .05s; }
.frame > .blurb  { animation-delay: .12s; }
.frame > #goForm { animation-delay: .19s; }
.frame > .legend { animation-delay: .26s; }

.brand { display: flex; align-items: baseline; gap: 14px; margin-bottom: 6px; }
.brand .logo { font-family: var(--disp); font-weight: 800; font-size: 76px; line-height: .82;
  letter-spacing: -.04em; color: var(--ink);
  background: linear-gradient(180deg, #fff, var(--amber)); -webkit-background-clip: text;
  background-clip: text; -webkit-text-fill-color: transparent; }
.brand .sub { font-size: 11px; letter-spacing: .42em; text-transform: uppercase; color: var(--amber-dim); }
.blurb { color: var(--dim); font-size: 13px; line-height: 1.6; margin: 4px 0 26px; max-width: 42ch; }

#goForm { display: flex; flex-direction: column; gap: 12px; }
.fld { display: flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: 10px;
  background: #0d0c0e; overflow: hidden; transition: border-color .2s, box-shadow .2s; }
.fld:focus-within { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(255,174,59,.12); }
.fld .pre { font-family: var(--disp); font-size: 18px; color: var(--amber); padding: 0 4px 0 16px; }
#goInput { flex: 1; padding: 15px 14px; background: transparent; border: 0; outline: 0;
  color: var(--ink); font-family: var(--mono); font-size: 15px; letter-spacing: .02em; }
#goInput::placeholder { color: #4f4b44; }
.row { display: flex; gap: 12px; }
#goSort { flex: 0 0 auto; padding: 13px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: #0d0c0e; color: var(--ink); font-family: var(--mono); font-size: 13px;
  text-transform: lowercase; cursor: pointer; }
#goForm button { flex: 1; padding: 13px 20px; border: 0; border-radius: 10px; cursor: pointer;
  font-family: var(--mono); font-weight: 700; font-size: 14px; letter-spacing: .08em;
  color: #1a1206; background: linear-gradient(180deg, #ffc25e, var(--amber));
  box-shadow: 0 6px 20px rgba(255,174,59,.25); transition: transform .12s var(--ease), box-shadow .2s; }
#goForm button:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(255,174,59,.35); }
#goForm button:active { transform: translateY(0); }

.legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 26px; padding-top: 20px;
  border-top: 1px solid var(--line); font-size: 11px; color: var(--dim);
  letter-spacing: .08em; text-transform: uppercase; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }

.hidden { display: none !important; }

@media (max-width: 640px) {
  #info { padding: 56px 16px 18px; }
  #help { display: none; }
  .brand .logo { font-size: 60px; }
}
