/* bento — archive-brutalism styling, matched to draftzero.xyz.
   Fonts intentionally fall back to system stacks (no external fonts) so the
   strict app-origin CSP (style-src/font-src 'self') stays clean. */
:root {
  --paper: #f3f1ec;
  --paper-warm: #e8e2d6;
  --ink: #0d0d0d;
  --charcoal: #282828;
  --muted: #6f6c64;
  --line: rgba(13, 13, 13, 0.22);
  --line-strong: rgba(13, 13, 13, 0.75);
  --blue: #1f5eff;
  --green: #a6ff00;
  --card: rgba(255, 252, 244, 0.72);
  --shadow: 0 24px 80px rgba(13, 13, 13, 0.14);
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", "IBM Plex Mono", Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: Impact, Haettenschweiler, "Arial Narrow Bold", "Inter Tight", var(--sans);
  --col: min(960px, calc(100vw - 32px));
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Paper page background (home, forms, prose pages). */
body.page {
  background:
    radial-gradient(circle at 18% 8%, rgba(31, 94, 255, 0.10), transparent 30%),
    radial-gradient(circle at 88% 16%, rgba(166, 255, 0, 0.08), transparent 28%),
    linear-gradient(180deg, #f7f4ed 0%, var(--paper) 48%, #ebe5da 100%);
}

body.page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image:
    linear-gradient(rgba(13, 13, 13, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 13, 13, 0.035) 1px, transparent 1px),
    radial-gradient(rgba(13, 13, 13, 0.18) 0.6px, transparent 0.8px);
  background-size: 72px 72px, 72px 72px, 8px 8px;
  mask-image: linear-gradient(180deg, black 0%, transparent 92%);
}

body.page::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.12;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Top bar ── */
.site-header {
  position: relative;
  z-index: 1;
  width: var(--col);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 0 16px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--charcoal);
  border-bottom: 1px solid var(--line);
}
.bar-left, .bar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bar-tag { color: var(--muted); }
a.bar-tag { color: var(--charcoal); }
.top-pill {
  border: 1px solid var(--line-strong);
  padding: 7px 10px;
  background: rgba(243, 241, 236, 0.7);
}
.brand { font-weight: 700; letter-spacing: 0.04em; color: var(--ink); }
.status-dot {
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(166, 255, 0, 0.15);
}

/* ── Main column ── */
.container {
  position: relative;
  z-index: 1;
  width: var(--col);
  margin: 0 auto;
  padding: 40px 0 8px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 22px;
}
.barcode-mini { display: inline-flex; align-items: end; gap: 2px; height: 20px; }
.barcode-mini span { display: block; width: 3px; background: var(--ink); opacity: 0.9; }
.barcode-mini span:nth-child(1) { height: 13px; }
.barcode-mini span:nth-child(2) { height: 20px; }
.barcode-mini span:nth-child(3) { height: 9px; }
.barcode-mini span:nth-child(4) { height: 17px; }
.barcode-mini span:nth-child(5) { height: 20px; }
.barcode-mini span:nth-child(6) { height: 12px; }
.barcode-mini span:nth-child(7) { height: 17px; }

h1 {
  margin: 0 0 16px;
  font-family: var(--display);
  font-size: clamp(34px, 5.6vw, 64px);
  line-height: 1.04;
  letter-spacing: 0.005em;
  word-spacing: 0.06em;
  text-transform: uppercase;
  max-width: 20ch;
}

.lede {
  max-width: 60ch;
  margin: 0 0 8px;
  font-size: clamp(17px, 1.8vw, 21px);
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--charcoal);
}

.muted { color: var(--muted); font-size: 13px; }

/* House-rules ticker (limits / retention). */
.ticker {
  list-style: none;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 18px 0 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.ticker li {
  border: 1px solid var(--line);
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.4);
}

/* ── Create form ── */
.create-form { display: flex; flex-direction: column; gap: 20px; margin: 30px 0 8px; }
.create-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.create-form input[type="text"],
.create-form select,
.create-form textarea {
  font-family: var(--sans);
  font-size: 15px;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
  padding: 12px 14px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: #fffaf0;
  transition: box-shadow 140ms ease;
}
.create-form input[type="text"]:focus,
.create-form select:focus,
.create-form textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 4px 4px 0 rgba(31, 94, 255, 0.18);
}
.create-form textarea {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  min-height: 280px;
  width: 100%;
}

/* File upload */
.file-input {
  font-family: var(--mono);
  font-size: 13px;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
  padding: 16px;
  border: 2px dashed var(--ink);
  background: #fffaf0;
  cursor: pointer;
}
.file-input::file-selector-button {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink);
  border: 0;
  padding: 9px 14px;
  margin-right: 14px;
  cursor: pointer;
}
.file-input::file-selector-button:hover { background: var(--blue); }

/* Paste fallback (collapsed by default) */
.paste-fallback { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.35); }
.paste-fallback > summary {
  cursor: pointer;
  padding: 11px 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none;
}
.paste-fallback[open] > summary { border-bottom: 1px solid var(--line); }
.paste-fallback > textarea { margin: 0; border: 0; background: #fffaf0; display: block; }
.paste-fallback > textarea:focus { box-shadow: none; }

/* ── Brutalist button ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  align-self: flex-start;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  padding: 13px 20px;
  min-height: 48px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 6px 6px 0 rgba(13, 13, 13, 0.18);
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 9px 9px 0 rgba(13, 13, 13, 0.18);
  text-decoration: none;
}
.btn.secondary { background: rgba(243, 241, 236, 0.7); color: var(--ink); }

.actions { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-top: 26px; }

/* ── Alerts & copy rows ── */
.alert {
  padding: 14px 16px;
  border: 2px solid var(--ink);
  background: #fffaf0;
  margin: 18px 0;
  box-shadow: 6px 6px 0 rgba(13, 13, 13, 0.10);
}
.alert-warn { border-color: var(--blue); }
.alert strong { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.06em; font-size: 13px; }

.copy-row { display: flex; gap: 0; margin: 10px 0; }
.copy-src {
  flex: 1;
  font-family: var(--mono);
  font-size: 13px;
  padding: 11px 13px;
  border: 2px solid var(--ink);
  border-right: 0;
  background: #fffaf0;
  color: var(--ink);
}
.copy-btn {
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 16px;
  cursor: pointer;
}
.copy-btn:hover { background: var(--blue); border-color: var(--blue); }

/* ── Prose (terms, abuse, messages) ── */
.prose { max-width: 70ch; }
.prose h2 { margin-top: 30px; font-size: 20px; letter-spacing: -0.02em; }
.prose p, .prose li { font-size: 16px; line-height: 1.55; color: var(--charcoal); }

/* ── Site footer ── */
.site-footer {
  position: relative;
  z-index: 1;
  width: var(--col);
  margin: 56px auto 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: end;
  padding: 28px 0 40px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.site-footer strong { color: var(--ink); }
.foot-id { line-height: 1.7; }
.stamp-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.tiny-stamp {
  border: 1px solid var(--line-strong);
  padding: 8px 10px;
  background: rgba(255, 252, 244, 0.55);
  color: var(--charcoal);
}
a.tiny-stamp:hover { background: var(--green); text-decoration: none; }

/* ── Paste view: chrome around the sandboxed iframe ── */
.view-body { margin: 0; height: 100vh; background: #fff; }
/* An <iframe> is a replaced element: with height:auto it keeps its intrinsic
   150px and ignores the `bottom` inset, so the height MUST be set explicitly. */
.paste-frame {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: calc(100vh - 52px);
  border: 0;
  background: #fff;
}
@supports (height: 100dvh) {
  .paste-frame { height: calc(100dvh - 52px); }
}
.chrome-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--paper);
  border-top: 2px solid var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--charcoal);
}
.chrome-dot {
  width: 8px; height: 8px; border-radius: 999px; flex: none;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(166, 255, 0, 0.15);
}
.chrome-title {
  font-weight: 700; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30ch;
}
.chrome-meta { color: var(--muted); white-space: nowrap; }
.chrome-actions { display: flex; gap: 8px; margin-left: auto; }
.chrome-brand { color: var(--muted); white-space: nowrap; }
.chrome-brand strong { color: var(--ink); }
.chrome-btn {
  border: 2px solid var(--ink);
  background: #fffaf0;
  color: var(--ink);
  border-radius: 0;
  padding: 7px 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
}
.chrome-btn:hover { background: var(--blue); border-color: var(--blue); color: var(--paper); text-decoration: none; }

@media (max-width: 620px) {
  .site-header, .site-footer { grid-template-columns: 1fr; flex-direction: column; align-items: flex-start; gap: 10px; }
  .chrome-meta, .chrome-brand { display: none; }
  h1 { font-size: clamp(34px, 11vw, 56px); }
}
