@import url("https://fonts.googleapis.com/css2?family=Lexend:wght@100..900&display=swap");

/* ── Reset ─────────────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

body,
h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

body {
  min-height: 100vh;
  line-height: 1.5;
}

h1,
h2,
h3,
h4,
button,
input,
label {
  line-height: 1.1;
}

h1,
h2,
h3,
h4 {
  text-wrap: balance;
}

img,
picture {
  max-width: 100%;
  display: block;
}

input,
button,
textarea,
select {
  font: inherit;
}

:target {
  scroll-margin-block: 5ex;
}

/* ── Design tokens ─────────────────────────────────────────────────── */

:root {
  color-scheme: light dark;

  --font-family: "Lexend", sans-serif;
  --text: #333;
  --text-strong: #000;
  --text-muted: #999;
  --text-faint: #ccc;
  --bg: #fff;
  --bg-alt: #f5f5f5;
  --accent: darkgoldenrod;
  --orange: #f97316;
  --orange-muted: #fdba74;
  --border: #e5e5e5;
  --link: #333;
  --link-visited: #888;
  --shadow: 0 1px 3px rgb(0 0 0 / 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #ccc;
    --text-strong: #fff;
    --text-muted: #666;
    --text-faint: #444;
    --bg: #111;
    --bg-alt: #1a1a1a;
    --accent: goldenrod;
    --orange: #f97316;
    --orange-muted: #9a3412;
    --border: #262626;
    --link: #ccc;
    --link-visited: #777;
    --shadow: 0 1px 3px rgb(0 0 0 / 0.3);
  }
}

/* ── Base ──────────────────────────────────────────────────────────── */

body {
  font-size: 1rem;
  font-family: var(--font-family);
  font-optical-sizing: auto;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--link);
  text-decoration-color: var(--text-faint);
}

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

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

/* ── Layout ────────────────────────────────────────────────────────── */

.container {
  width: min(100%, 48rem);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

/* ── Header ────────────────────────────────────────────────────────── */

hnr-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-block: 0.75rem;
}

hnr-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

hnr-header h1 a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  text-decoration: none;
}

hnr-header h1 a:visited {
  color: var(--text-muted);
}

hnr-header h1 img {
  width: 1.5rem;
  height: 1.5rem;
}

.badge-link {
  margin-left: auto;
}

.badge-link[hidden] {
  display: none;
}

.badge {
  display: inline-block;
  min-width: 1.5rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  line-height: 1.4;
}

.badge:visited {
  color: #fff;
}

/* ── Story list ────────────────────────────────────────────────────── */

story-list {
  display: block;
}

story-row {
  display: block;
  padding-block: 0.625rem;
  border-top: 1px solid var(--border);
}

story-row:first-child {
  border-top: none;
}

story-row.previous-recent {
  border-top: 2px dotted var(--orange);
}

/* ── Story title row ───────────────────────────────────────────────── */

story-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.25rem;
  position: relative;
}

story-title.unread::before {
  content: "•";
  position: absolute;
  left: -0.85rem;
  line-height: 1;
  font-size: 1.25rem;
  color: var(--orange);
}

story-title a {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
}

story-title a:hover {
  text-decoration: underline;
}

story-title a:visited {
  color: var(--text-muted);
}

story-title .story-time {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding-top: 0.2rem;
  cursor: pointer;
}

/* ── Story meta row ────────────────────────────────────────────────── */

.story-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.375rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.story-meta a {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  text-decoration: none;
  color: var(--text-muted);
}

.story-meta a:visited {
  color: var(--text-faint);
}

.story-meta a:hover {
  text-decoration: underline;
}

.story-meta .points-front-page {
  color: var(--orange);
}

.story-meta .points-front-page:visited {
  color: var(--orange-muted);
}

.story-meta .points-above-median {
  font-weight: 600;
}

.story-meta svg {
  width: 0.8rem;
  height: 0.8rem;
}

.story-host {
  color: var(--text-muted);
}

/* ── Tags ──────────────────────────────────────────────────────────── */

.story-tags {
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
}

.tag {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--text-faint);
  border-radius: 999px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── OG Description ────────────────────────────────────────────────── */

.story-og {
  margin-top: 0.375rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-og .og-author {
  font-style: italic;
}

/* ── Debug panel ───────────────────────────────────────────────────── */

.debug-toggle {
  display: none;
}

.debug-panel {
  display: none;
  margin-top: 0.5rem;
}

.debug-toggle:checked + .debug-panel {
  display: block;
}

.debug-panel pre {
  font-size: 0.75rem;
  overflow-x: auto;
}

/* ── Footer ────────────────────────────────────────────────────────── */

footer {
  margin-top: 2rem;
  padding-block: 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.5rem;
}

footer a {
  color: var(--text-muted);
}

/* ── SVG icon sprite (visually hidden) ─────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ── Progressive enhancement: view transitions ─────────────────────── */

@view-transition {
  navigation: auto;
}

/* ── Progressive enhancement: squircle cards (future) ──────────────── */

@supports (corner-shape: squircle) {
  .tag {
    corner-shape: squircle;
    border-radius: 6px;
  }
}

/* ── Scroll-driven sticky header ───────────────────────────────────── */

@supports (animation-timeline: scroll()) {
  hnr-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
  }

  hnr-header.stuck {
    border-bottom-color: var(--border);
    box-shadow: var(--shadow);
  }
}
