/* hackerniouz — « Tramé 3615 ».
   A Minitel 1 screen: monochrome, colours rendered as levels of grey, dithered
   rules. Terminal type (VT323) for the interface, a reading face for content.
   One accent, orange, marks what you voted for.
   Both themes come from light-dark(); theme.js pins data-theme when chosen. */

:root {
  color-scheme: light dark;
  --bg:     light-dark(#e6e7e3, #1b1d1d);
  --fg:     light-dark(#2a2c2b, #d5d8d3);
  --strong: light-dark(#1d1f1e, #eef0ec);
  --meta:   light-dark(#5e635f, #979d98);
  --accent: light-dark(#d9542e, #ff8a5c);
  --field:  light-dark(#f2f3f0, #232626);
  --dot:    light-dark(rgba(42, 44, 43, .34), rgba(213, 216, 211, .26));
  --g1: light-dark(#c9cbc6, #2c2f2e);
  --g2: light-dark(#a9aca7, #4a4e4c);
  --g3: light-dark(#7d817d, #7a7f7b);
  --g4: light-dark(#4c4f4d, #b3b8b3);

  --f-ui: "VT323", "Courier New", monospace;
  --f-text: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --f-mono: "Geist Mono", ui-monospace, monospace;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  padding: 16px;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 var(--f-text);
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.screen { max-width: 980px; margin: 0 auto; border: 2px solid var(--fg); }

/* ---- header: title bar, dithered menu bar, grey mosaic ---- */
.titlebar {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 12px;
  border-bottom: 2px solid var(--fg);
  font: 22px/1 var(--f-ui);
  background: repeating-linear-gradient(to bottom, var(--dot) 0 1px, transparent 1px 3px) center / 100% 11px no-repeat;
}
.titlebar .tag { background: var(--fg); color: var(--bg); padding: 1px 7px; }
.titlebar .name { background: var(--bg); padding: 0 8px; color: var(--strong); text-transform: uppercase; letter-spacing: .06em; }
.titlebar .pg { margin-left: auto; background: var(--bg); padding: 0 6px; color: var(--meta); font-size: 19px; }
.titlebar a:hover { text-decoration: none; }

.bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  padding: 8px 12px;
  border-bottom: 2px solid var(--fg);
  font: 20px/1.1 var(--f-ui);
  background-image: radial-gradient(var(--dot) .8px, transparent 1px);
  background-size: 3px 3px;
}
.bar .home { display: block; background: var(--bg); padding: 2px 3px; }
.logo .f { fill: var(--fg); }
.logo .a { fill: var(--accent); }
.nav { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.nav a, .me > * { background: var(--bg); padding: 0 5px; }
.nav a.cur, .me a.cur { background: var(--fg); color: var(--bg); }
.me { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.karma { color: var(--meta); padding-left: 0 !important; }
.theme { display: inline-flex; align-items: center; height: 22px; }
.theme svg { display: block; }
.theme .c, .arrow .c { fill: currentColor; }
.theme .sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme .sun { display: block; }
  :root:not([data-theme="light"]) .theme .moon { display: none; }
}
:root[data-theme="dark"] .theme .sun { display: block; }
:root[data-theme="dark"] .theme .moon { display: none; }

.mosaic { display: grid; grid-template-columns: repeat(32, 1fr); height: 6px; border-bottom: 2px solid var(--fg); }
.mosaic i:nth-child(4n+1) { background: var(--g1); }
.mosaic i:nth-child(4n+2) { background: var(--g2); }
.mosaic i:nth-child(4n+3) { background: var(--g3); }
.mosaic i:nth-child(4n) { background: var(--g4); }
.mosaic i:nth-child(7n) { background: var(--accent); }

main { padding: 14px 12px 6px; min-height: 50vh; }

/* ---- shared bits ---- */
.link { text-decoration: underline; color: inherit; }
form.inline { display: inline; }
.sep { color: var(--meta); }
.heading { margin: 0 0 14px; color: var(--meta); }
.empty { margin: 24px 0; font: 22px/1.2 var(--f-ui); }
.hint { color: var(--meta); font-size: .9em; }
.hint a { text-decoration: underline; }
.links { font: 20px/1.2 var(--f-ui); }
.links a { text-decoration: underline; }
.error { border: 2px solid var(--accent); padding: 6px 10px; margin: 0 0 14px; }

/* ---- votes ---- */
.vote { width: 14px; padding-top: 5px; }
.up { display: block; color: var(--g3); padding: 2px 0; }
.up:hover { color: var(--fg); }
.voted > .vote .up { color: var(--accent); cursor: default; }
.unvote { display: none; }
.voted > * .unvote { display: inline; }
.own { font: 20px/1 var(--f-ui); color: var(--meta); }

/* ---- stories ---- */
.stories { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.story { display: grid; grid-template-columns: 3ch 14px 1fr; gap: 0 8px; align-items: start; }
.stories.single .story { grid-template-columns: 14px 1fr; }
.rank { font: 20px/1.1 var(--f-ui); color: var(--meta); text-align: right; font-variant-numeric: tabular-nums; }
.title { color: var(--strong); font-weight: 600; font-size: 1.02em; }
.title:visited {
  background: conic-gradient(var(--dot) 25%, transparent 0 50%, var(--dot) 0 75%, transparent 0) 0 100% / 2px 2px repeat-x;
  padding-bottom: 2px;
}
.domain { color: var(--meta); font: .8em var(--f-mono); }
.meta { color: var(--meta); font-size: .82em; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; }
.meta a:hover { color: var(--fg); }
.meta .pts { font: 17px/1 var(--f-ui); color: var(--fg); }
.story-text { margin: 10px 0 0 22px; }

/* ---- comments ---- */
.thread { margin-top: 18px; display: grid; gap: 12px; }
.comment { display: grid; grid-template-columns: 14px 1fr; gap: 0 8px; }
.comment .author { color: var(--fg); font-weight: 600; }
.d1 { margin-left: 2em; } .d2 { margin-left: 4em; } .d3 { margin-left: 6em; } .d4 { margin-left: 8em; }
.d5 { margin-left: 10em; } .d6 { margin-left: 12em; } .d7 { margin-left: 14em; } .d8 { margin-left: 16em; }
.reply { color: var(--meta); font-size: .82em; text-decoration: underline; }

.text { max-width: 72ch; overflow-wrap: anywhere; }
.text p { margin: 3px 0 6px; }
.text a { text-decoration: underline; }
.text pre { margin: 6px 0; padding: 8px 10px; background: var(--field); border-left: 2px solid var(--g2); overflow-x: auto; font: .88em/1.5 var(--f-mono); }

/* ---- forms ---- */
.form { display: grid; gap: 6px; max-width: 640px; margin-bottom: 8px; }
.form h2 { font: 24px/1 var(--f-ui); margin: 0 0 6px; }
.form label { font: 19px/1 var(--f-ui); margin-top: 6px; }
input, textarea {
  font: inherit; color: var(--strong);
  background: var(--field);
  border: 2px solid var(--fg);
  padding: 6px 8px;
  width: 100%;
  border-radius: 0;
}
textarea { resize: vertical; min-height: 7em; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
.compose { margin: 16px 0 6px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 6px; }
.auth { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 28px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Minitel function keys: RETOUR, SUITE, ENVOI */
.key { display: inline-flex; font: 20px/1 var(--f-ui); color: var(--fg); }
.key b { font-weight: 400; background: var(--fg); color: var(--bg); padding: 3px 10px; box-shadow: 3px 3px 0 var(--accent); }
.key:hover { text-decoration: none; }
.key:hover b { box-shadow: 1px 1px 0 var(--accent); transform: translate(2px, 2px); }
.keys { display: flex; justify-content: space-between; margin: 18px 0 4px; padding-top: 12px; border-top: 2px dotted var(--fg); }

/* ---- profile, prose ---- */
.profile { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; }
.profile dt { font: 19px/1.2 var(--f-ui); color: var(--meta); }
.profile dd { margin: 0; }
.prose { max-width: 70ch; }
.prose h1 { font: 30px/1 var(--f-ui); margin: 4px 0 12px; }
.prose h2 { font: 24px/1 var(--f-ui); margin: 22px 0 6px; }
.prose ul { padding-left: 1.2em; }
.prose li { margin: 4px 0; }

.foot {
  margin: 0 12px; padding: 10px 0 12px;
  border-top: 2px dotted var(--fg);
  text-align: center;
  font: 19px/1.3 var(--f-ui);
  color: var(--meta);
}
.foot a:hover { color: var(--fg); }

@media (max-width: 640px) {
  body { padding: 8px; }
  .me { margin-left: 0; }
  .titlebar .pg { display: none; }
  .d1, .d2, .d3, .d4, .d5, .d6, .d7, .d8 { margin-left: 0; }
  .comment[class*=" d"]:not(.d0) { border-left: 2px dotted var(--g2); padding-left: 6px; }
  .d2 { margin-left: .75em; } .d3 { margin-left: 1.5em; } .d4, .d5, .d6, .d7, .d8 { margin-left: 2.25em; }
  .d1 { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .key:hover b { transform: none; }
}
