/* ============================================================
   Design language modeled on offshore.cx
   Pure black bg, blue links, red accents, utilitarian tables,
   system-ui 15px, max-width 1280px centered, top nav.
   ============================================================ */
:root {
  color-scheme: dark;
  --bg: #000;
  --panel: #0d0d0d;
  --zebra: #0e0e0e;
  --raised: #1a1a1a;
  --line: #3a3a3a;
  --line-soft: #222;
  --input-line: #555;
  --text: #d6d6d6;
  --text2: #a8a8a8;
  --muted: #8a8a8a;
  --faint: #777;
  --heading: #eee;
  --link: #7ab8ff;
  --link-visited: #b99cff;
  --link-hover: #a9d0ff;
  --red: #e04848;
  --red-deep: #b22;
  --gold: #e0b030;
  --green: #4cc35a;
  --purple: #b99cff;
  --orange: #d08a2a;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  color: var(--text);
  background: var(--bg);
  margin: 0 auto;
  padding: 14px 24px 28px;
  max-width: 1280px;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "DejaVu Sans", sans-serif;
}

a { color: var(--link); }
a:visited { color: var(--link-visited); }
a:hover { color: var(--link-hover); }

h1 { color: var(--heading); margin: 0 0 8px; font-size: 26px; }
h2 { color: var(--heading); margin: 18px 0 8px; font-size: 18px; }
h3 { color: var(--heading); margin: 16px 0 6px; font-size: 15px; }
p  { margin: 0 0 8px; }
ul, ol { margin: 0 0 10px; padding-left: 24px; }
li { margin: 2px 0; }
b, strong { color: var(--heading); }
hr { border: 0; border-top: 1px solid #333; margin: 14px 0; }
code { word-break: break-all; background: #141414; border: 1px solid #333; padding: 0 3px; font: 12px "DejaVu Sans Mono", Consolas, monospace; }

.muted { color: var(--muted); }
.dim, .faint { color: var(--faint); }
.small { font-size: 12px; }
.mono { font-family: "DejaVu Sans Mono", Consolas, monospace; }
.red { color: var(--red); }
.gold { color: var(--gold); }
.green { color: var(--green); }

/* ---------------- Header (offshore .hd) ---------------- */
.hd {
  border-bottom: 2px solid var(--red-deep);
  align-items: center;
  gap: 10px;
  padding-bottom: 6px;
  display: flex;
}
.hd .logo {
  height: 64px;
  width: 64px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
  color: var(--heading);
  background: var(--panel);
  border: 1px solid var(--line);
}
.hd .logo span { color: var(--red); }
.hd .ti { min-width: 0; }
.hd h1 { margin: 0; font-size: 28px; }
.hd h1 a { color: var(--heading); text-decoration: none; }
.hd h1 a span { color: var(--red); }
.hd .t { color: var(--muted); font-size: 13px; }
.hd .r { text-align: right; margin-left: auto; font-size: 13px; }

/* ---------------- Top nav (offshore .catgrid) ---------------- */
.catgrid {
  border-top: 1px solid var(--line-soft);
  margin: 6px 0 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0 14px;
}
.catgrid a {
  color: #cfcfcf;
  border-bottom: 1px solid var(--line-soft);
  border-left: 2px solid transparent;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 6px 8px;
  text-decoration: none;
  display: flex;
}
.catgrid a:visited { color: #cfcfcf; }
.catgrid a:hover { color: #fff; background: var(--panel); }
.catgrid a[aria-current="page"] {
  color: #fff;
  border-left-color: var(--c, var(--link));
  background: var(--panel);
  font-weight: 700;
}

/* ---------------- Sections & cards ---------------- */
.section { margin: 22px 0; }
.section-header { border-bottom: 1px solid var(--line-soft); margin-bottom: 10px; padding-bottom: 4px; }
.section-header h2 { margin: 0 0 2px; }
.section-header .desc { color: var(--muted); font-size: 13px; margin: 0 0 4px; }

.panel, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  margin-bottom: 14px;
  padding: 8px 10px;
}
.card h3, .panel h3 { margin: 2px 0 6px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 16px; }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }

/* ---------------- Tables (offshore list/kv) ---------------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; }
table.list, table.kv { width: 100%; margin-bottom: 10px; }
table.list th, table.list td, table.kv th, table.kv td {
  vertical-align: top;
  text-align: left;
  border: 1px solid var(--line);
  padding: 4px 6px;
}
table.list th {
  color: #e6e6e6;
  white-space: nowrap;
  background: var(--raised);
  font-size: 13px;
}
table.list tbody tr:nth-child(2n) td { background: var(--zebra); }
table.kv th { color: #bdbdbd; background: #121212; width: 170px; font-weight: 400; }
table.kv td { overflow-wrap: anywhere; }

/* ---------------- Badges / status pills ---------------- */
.badge {
  display: inline-block;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
  white-space: nowrap;
}
.badge.gold   { color: var(--gold);   border-color: var(--gold); }
.badge.green  { color: var(--green);  border-color: var(--green); }
.badge.red    { color: #ff5b5b;       border-color: #ff5b5b; }
.badge.orange { color: var(--orange); border-color: var(--orange); }
.badge.purple { color: var(--purple); border-color: var(--purple); }
.badge.blue   { color: var(--link);   border-color: var(--link); }
.badge.muted  { color: var(--muted); }

/* Stat numbers */
.stat { text-align: center; }
.stat .num { font-size: 28px; font-weight: 700; color: var(--gold); }
.stat .lbl { font-size: 12px; color: var(--muted); }

/* ---------------- Forms / buttons ---------------- */
input, select, textarea {
  color: #e6e6e6;
  background: var(--panel);
  border: 1px solid var(--input-line);
  padding: 4px 6px;
  font: inherit;
  font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--link); }
textarea { width: 100%; max-width: 700px; min-height: 80px; }

button, .btn {
  color: #e6e6e6;
  cursor: pointer;
  background: #1c1c1c;
  border: 1px solid #5a5a5a;
  padding: 2px 10px;
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { color: #fff; background: #2a2a2a; }
button.primary, .btn-primary { background: #6e1c1c; border-color: #a33; }
button.primary:hover, .btn-primary:hover { background: #842222; }
button.danger { color: #ff8a8a; }
.btn-sm { padding: 1px 6px; font-size: 12px; }
button:disabled { opacity: .55; cursor: default; }
@media (prefers-reduced-motion: no-preference) {
  button:not(.link), .btn { transition: transform .12s var(--ease-out); }
  button:not(.link):active:not(:disabled), .btn:active { transform: scale(.97); }
}

/* ---------------- Editing UI ---------------- */
#edit-toggle.on {
  background: #6e1c1c;
  border-color: #a33;
  color: #fff;
}
.save-status { font-size: 12px; color: var(--muted); min-height: 18px; margin-top: 2px; }
.save-status.ok { color: var(--green); }
.save-status.err { color: #ff5b5b; }

body.editing [data-field] {
  outline: 1px dashed #4a4a4a;
  outline-offset: 1px;
  cursor: text;
  min-width: 1ch;
}
body.editing [data-field]:hover { outline-color: var(--link); }
body.editing [data-field]:focus { outline: 1px solid var(--link); background: #101018; }
body.editing [data-field].field-dirty { outline-color: var(--gold); }
body.editing [data-field].field-saved { outline-color: var(--green); }
body.editing [data-field].field-error { outline-color: #ff5b5b; }

.edit-row-tools { display: none; gap: 4px; margin-left: 6px; }
/* hide the empty edit-only table column entirely when not editing */
body:not(.editing) table td:has(> .edit-row-tools:only-child),
body:not(.editing) table th:empty { display: none; }
body.editing .edit-row-tools { display: inline-flex; }
.edit-add { display: none; margin: 2px 0 10px; }
body.editing .edit-add { display: inline-block; }

/* Toast */
#toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: #1c1c1c;
  border: 1px solid #5a5a5a;
  color: #e6e6e6;
  padding: 6px 12px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s var(--ease-out);
  z-index: 99;
}
#toast.show { opacity: 1; }
#toast.err { border-color: #ff5b5b; color: #ff8a8a; }

/* ---------------- Custom page canvas (macOS-style free drag) ---------------- */
.canvas-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0 10px; }
.canvas-toolbar.edit-add { display: none; }
body.editing .canvas-toolbar.edit-add { display: flex; }
.canvas-toolbar .spacer { flex: 1; }
.canvas {
  position: relative;
  min-height: 70vh;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
  background-image: radial-gradient(circle, #1e1e1e 1px, transparent 1px);
  background-size: 24px 24px;
}
.canvas-empty { color: var(--muted); position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; pointer-events: none; }
.el { position: absolute; }
.el img, .el video { width: 100%; display: block; }
.el-text {
  min-width: 120px;
  max-width: 640px;
  padding: 6px 8px;
  background: rgba(13, 13, 13, .85);
  border: 1px solid var(--line);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
body.editing .el { outline: 1px dashed #4a4a4a; outline-offset: 2px; cursor: move; user-select: none; }
body.editing .el:hover { outline-color: var(--link); }
body.editing .el.dragging { outline: 1px solid var(--gold); z-index: 10; }
body.editing .el-text { cursor: move; }
body.editing .el-text:focus { cursor: text; }
.el-tools { position: absolute; top: -12px; right: -12px; display: none; z-index: 11; }
body.editing .el-tools { display: block; }
.el-tools button { padding: 0 5px; font-size: 11px; line-height: 1.5; }
.el-resize {
  position: absolute; right: -6px; bottom: -6px; width: 12px; height: 12px;
  background: var(--link); border: 1px solid #000; display: none; cursor: nwse-resize; z-index: 11;
}
body.editing .el-resize { display: block; }
.drop-hint { border-color: var(--link) !important; }

/* ---------------- Biography in-text links ---------------- */
a.archive-link, a.archive-link:visited {
  color: #ff6a33; /* reddit orange */
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
a.archive-link:hover { color: #ff8a5c; text-decoration-style: solid; }
a.page-link, a.page-link:visited {
  color: var(--link); /* info blue */
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
a.page-link:hover { color: var(--link-hover); text-decoration-style: solid; }

/* ---------------- DVD bouncing logos ---------------- */
.dvd-logo { position: fixed; z-index: 60; pointer-events: none; }
.dvd-logo img { width: 100%; display: block; }
@media (max-width: 700px) {
  /* translucent on mobile so the bouncing logos never hide text */
  .dvd-logo { opacity: 0.55; }
}
body.editing .dvd-logo { pointer-events: auto; cursor: pointer; outline: 1px dashed #4a4a4a; }
.dvd-tools { position: absolute; top: -12px; right: -12px; display: none; z-index: 61; }
body.editing .dvd-tools { display: block; }

/* ---------------- Jumpscare ---------------- */
.jumpscare-btn {
  position: fixed; left: 16px; bottom: 16px; z-index: 70;
  background: none !important; border: none; padding: 0; cursor: pointer;
  animation: js-rgb 0.35s linear infinite, js-pulse 0.7s ease-in-out infinite;
}
.jumpscare-btn:hover, .jumpscare-btn:active { background: none !important; transform: none; }
.jumpscare-btn img { height: 96px; display: block; filter: drop-shadow(0 0 12px #ff4500); }
@keyframes js-rgb {
  0%   { filter: hue-rotate(0deg)   brightness(1); }
  25%  { filter: hue-rotate(90deg)  brightness(1.35); }
  50%  { filter: hue-rotate(180deg) brightness(1); }
  75%  { filter: hue-rotate(270deg) brightness(1.35); }
  100% { filter: hue-rotate(360deg) brightness(1); }
}
@keyframes js-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}
.jumpscare-overlay {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  background: #000; cursor: pointer; animation: js-bg 0.18s steps(2, jump-none) infinite;
}
.jumpscare-overlay img {
  width: 100vw; height: 100vh; object-fit: fill; /* stretched to the whole screen */
  animation: js-shake 0.09s infinite;
}
@keyframes js-bg { 0% { background: #000; } 50% { background: #1a0000; } 100% { background: #000; } }
@keyframes js-shake {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-8px, 4px); }
  50%  { transform: translate(6px, -6px); }
  75%  { transform: translate(-4px, -2px); }
  100% { transform: translate(0, 0); }
}
.ft {
  color: var(--muted);
  overflow-wrap: anywhere;
  border-top: 1px solid #333;
  margin-top: 16px;
  padding-top: 6px;
  font-size: 13px;
}

@media (max-width: 700px) {
  body { padding: 10px 14px 24px; }
  .hd { flex-wrap: wrap; gap: 6px 10px; }
  .hd .logo { height: 50px; width: 50px; font-size: 24px; }
  .hd h1 { font-size: 24px; }
  .hd .r { text-align: left; width: 100%; margin-left: 0; }
  table.kv th { width: 120px; }
}

/* ============================================================
   REDDIT ARCHIVE VIEWER (/archive/)
   New section — appended only, no existing rules touched.
   Reddit accent #ff4500; utilitarian offshore look:
   1px borders, max 4px radius, panels on black.
   ============================================================ */
:root { --reddit: #ff4500; }

/* ---------------- Tabs ---------------- */
.av-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}
.av-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--text2);
  padding: 6px 12px;
  font-size: 14px;
}
.av-tab:hover { color: #fff; background: var(--panel); }
.av-tab[aria-selected="true"] {
  color: #fff;
  font-weight: 700;
  border-bottom-color: var(--reddit);
}
.av-tab .n {
  color: var(--reddit);
  font-size: 12px;
  font-weight: 700;
  margin-left: 6px;
}

/* ---------------- Controls row ---------------- */
.av-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px 10px;
}
.av-controls input#q { flex: 1 1 260px; min-width: 0; }
.av-controls select { flex: 0 1 auto; max-width: 100%; }

.av-help { font-size: 13px; line-height: 1.8; }
.av-count { font-size: 13px; margin: 4px 0 10px; }

/* ---------------- Result cards ---------------- */
.av-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}
.av-item.deleted { border-left: 3px solid #ff5b5b; }

.av-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
  font-size: 13px;
}
.av-sr { color: var(--text); font-weight: 700; }

.av-pill {
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text2);
  font-size: 12px;
  padding: 0 6px;
  white-space: nowrap;
}
.av-pill.del { color: #ff8a8a; border-color: #ff5b5b; }

.av-title { font-size: 16px; font-weight: 700; line-height: 1.3; margin: 4px 0 2px; }
.av-title a { color: var(--heading); text-decoration: none; }
.av-title a:hover { color: var(--link-hover); text-decoration: underline; }

.av-thread { color: var(--muted); font-size: 13px; margin: 4px 0 2px; }
.av-thread b { color: var(--text); font-weight: 600; }

.av-body { margin-top: 6px; font-size: 14px; }
.av-body p { margin: 6px 0; }
.av-body blockquote {
  border-left: 3px solid var(--line);
  background: #111;
  margin: 6px 0;
  padding: 4px 10px;
  border-radius: 0 4px 4px 0;
}
.av-body pre {
  background: #111;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 8px 10px;
  overflow-x: auto;
  white-space: pre-wrap;
}
.av-body pre code { background: none; border: none; padding: 0; }
.av-body ul, .av-body ol { padding-left: 22px; margin: 6px 0; }
.av-body h3, .av-body h4, .av-body h5, .av-body h6 { margin: 8px 0 4px; }
.av-body table { display: block; overflow-x: auto; border-collapse: collapse; margin: 6px 0; }
.av-body td, .av-body th { border: 1px solid var(--line); padding: 3px 8px; }
.av-body hr { margin: 8px 0; }
.av-empty-body { color: var(--muted); font-style: italic; }

.spoiler { background: var(--text); color: transparent; border-radius: 2px; cursor: pointer; }
.spoiler.open { background: #222; color: inherit; }

.av-ext { display: block; font-size: 13px; margin-top: 6px; overflow-wrap: anywhere; }

/* Media thumbnails — click opens full file */
.av-media { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.av-media a { display: block; border: 1px solid var(--line); border-radius: 4px; line-height: 0; }
.av-media img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 3px;
  display: block;
}

/* Search-term highlight */
.av-item mark {
  background: #ff450033;
  color: #ffb399;
  border-radius: 2px;
  padding: 0 1px;
}

/* ---------------- Pager ---------------- */
.av-pager {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
}
.av-pager:empty { display: none; }
.av-pager button {
  min-width: 32px;
  font-size: 13px;
  padding: 3px 8px;
}
.av-pager button[aria-current="page"] {
  background: var(--reddit);
  border-color: var(--reddit);
  color: #fff;
  font-weight: 700;
}
.av-pager .gap { color: var(--muted); padding: 0 4px; }
.av-pager label {
  color: var(--muted);
  display: flex;
  gap: 4px;
  align-items: center;
  font-size: 13px;
  margin-left: 6px;
}
.av-pager input { width: 60px; font-size: 13px; padding: 3px 6px; }

/* ---------------- Notes / empty state ---------------- */
.av-note {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-size: 13px;
  padding: 8px 12px;
  margin-bottom: 8px;
}
.av-none { color: var(--muted); text-align: center; padding: 40px 0; }

/* ---------------- Find the cosmins ---------------- */
#cosmins-counter {
  position: fixed; right: 16px; bottom: 16px; z-index: 75;
  background: #0d0d0d; border: 1px solid #3a3a3a; color: var(--text2);
  font-size: 13px; padding: 4px 10px; border-radius: 6px; user-select: none;
}
#cosmins-counter.done { border-color: var(--gold); color: var(--gold); }
.cosmin-spawn {
  position: absolute; z-index: 40; cursor: pointer; user-select: none;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.6));
  transition: transform .12s ease;
}
.cosmin-spawn:hover { transform: scale(1.08); }
.cosmin-spawn:active { transform: scale(0.9); }
.cosmin-spawn.found { opacity: 0; transform: scale(1.4); transition: opacity .18s, transform .18s; }
.cosmin-spawn.tutorial {
  animation: cosmin-glow 1.2s ease-in-out infinite;
}
@keyframes cosmin-glow {
  0%, 100% { filter: drop-shadow(0 0 4px #e0b030); }
  50%      { filter: drop-shadow(0 0 16px #e0b030); }
}
@media (max-width: 700px) {
  .cosmin-spawn { width: 60px; height: 60px; }
}
