@import "./brand-system.css";

:root {
  color-scheme: light dark;
  --good: #26734d;
  --good-dark: #174c33;
  --good-soft: #e7f3ec;
  --page: #f3f5f4;
  --surface: #ffffff;
  --surface-raised: #f8faf9;
  --ink: #17211b;
  --muted: #59645e;
  --line: #d7ddd9;
  --shadow: 0 18px 50px rgb(31 60 43 / 0.1);
  --radius: 8px;
  font-family: var(--font-ui, Inter, ui-sans-serif, system-ui, sans-serif);
  background: var(--page);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--page);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--page);
  color: var(--ink);
}

button,
a,
summary {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

a {
  color: inherit;
}

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

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--surface);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px max(20px, calc((100vw - 1320px) / 2));
  border-bottom: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  background: color-mix(in srgb, var(--page) 90%, transparent);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  width: 16px;
  height: 16px;
  border: 5px solid var(--good);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--surface);
}

.starred-filter,
.secondary-button {
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
  cursor: pointer;
}

.starred-filter[aria-pressed="true"] {
  border-color: var(--good);
  background: var(--good);
  color: #ffffff;
}

.starred-filter:active,
.secondary-button:active,
.tag-button:active,
.favorite-button:active {
  transform: translateY(1px);
}

main {
  width: min(1320px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 80px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 36px;
  margin-bottom: 36px;
}

.kicker {
  margin: 0 0 10px;
  color: var(--good);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 14px;
  font-size: clamp(44px, 7vw, 88px);
  line-height: 0.95;
  letter-spacing: -0.065em;
}

.lede {
  max-width: 580px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.today-status {
  display: grid;
  gap: 4px;
  min-width: 230px;
  padding: 16px 18px;
  border-left: 3px solid var(--good);
}

.today-status strong {
  font-size: 17px;
}

.today-status span {
  color: var(--muted);
  font-size: 14px;
}

.tag-filter {
  display: flex;
  gap: 8px;
  margin: 0 0 28px;
  padding: 4px 0 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tag-filter::-webkit-scrollbar {
  display: none;
}

.tag-button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
}

.tag-button[aria-pressed="true"] {
  border-color: var(--good);
  background: var(--good-soft);
  color: var(--good-dark);
}

.day-group {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: clip;
}

.day-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  min-height: 68px;
  padding: 16px 20px;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}

.day-summary::-webkit-details-marker {
  display: none;
}

.day-summary::after {
  content: "+";
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--good);
  font-size: 22px;
  line-height: 27px;
  text-align: center;
}

.day-group[open] > .day-summary::after {
  content: "−";
}

.day-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.day-title strong {
  font-size: 20px;
}

.day-title span {
  color: var(--muted);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 13px;
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  padding: 0 16px 16px;
}

.story-card {
  grid-column: span 5;
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  overflow: hidden;
}

.story-card:nth-child(4n + 1),
.story-card:nth-child(4n + 4) {
  grid-column: span 7;
}

.story-image-link {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--good-soft);
}

.story-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.story-card:hover .story-image {
  transform: scale(1.025);
}

.story-body {
  display: flex;
  min-height: 260px;
  flex-direction: column;
  padding: 20px;
}

.story-tag {
  align-self: flex-start;
  margin-bottom: 14px;
  color: var(--good);
  font-size: 13px;
  font-weight: 800;
}

.story-title {
  margin-bottom: 12px;
  font-size: clamp(21px, 2.2vw, 30px);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.story-title a {
  text-decoration-thickness: 1px;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
}

.story-title a:hover {
  text-decoration-color: var(--good);
}

.story-summary {
  display: -webkit-box;
  margin-bottom: 22px;
  overflow: hidden;
  color: var(--muted);
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.story-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.story-meta {
  display: grid;
  gap: 3px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.story-meta a {
  overflow: hidden;
  color: var(--ink);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorite-button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.favorite-button[aria-pressed="true"] {
  border-color: var(--good);
  background: var(--good-soft);
  color: var(--good-dark);
}

.loading-state {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

.skeleton {
  min-height: 430px;
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--surface) 10%, var(--good-soft) 45%, var(--surface) 80%);
  background-size: 220% 100%;
}

.skeleton-large {
  min-height: 520px;
  grid-row: span 2;
}

.empty-state,
.error-state {
  padding: 64px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.empty-state p,
.error-state p {
  color: var(--muted);
}

footer {
  display: grid;
  gap: 14px;
  padding: 36px max(20px, calc((100vw - 1320px) / 2));
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

footer p {
  max-width: 760px;
  margin-bottom: 0;
}

#sourceLinks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

footer a {
  color: var(--ink);
  font-weight: 750;
  text-underline-offset: 3px;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--good) 60%, transparent);
  outline-offset: 3px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --good: #78c99e;
    --good-dark: #b8efd0;
    --good-soft: #183427;
    --page: #111714;
    --surface: #18201c;
    --surface-raised: #1d2721;
    --ink: #edf5f0;
    --muted: #b3c0b8;
    --line: #34423a;
    --shadow: 0 18px 50px rgb(0 0 0 / 0.28);
  }

  .starred-filter[aria-pressed="true"] {
    color: #102117;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .skeleton {
    animation: shimmer 1.6s linear infinite;
  }
}

@keyframes shimmer {
  to {
    background-position: -220% 0;
  }
}

@media (max-width: 760px) {
  .app-header {
    min-height: 62px;
    padding-inline: 16px;
  }

  .starred-filter {
    min-height: 44px;
  }

  main {
    width: calc(100% - 24px);
    padding: 32px 0 56px;
  }

  .intro {
    grid-template-columns: 1fr;
    gap: 22px;
    margin-bottom: 24px;
  }

  h1 {
    font-size: clamp(42px, 15vw, 64px);
  }

  .lede {
    font-size: 16px;
  }

  .today-status {
    min-width: 0;
    padding-block: 10px;
  }

  .tag-button {
    min-height: 44px;
  }

  .day-summary {
    min-height: 64px;
    padding: 14px;
  }

  .day-title {
    display: grid;
    gap: 3px;
  }

  .story-grid {
    display: block;
    padding: 0 10px 10px;
  }

  .story-card {
    margin-bottom: 10px;
  }

  .story-body {
    min-height: 0;
    padding: 18px;
  }

  .story-title {
    font-size: 24px;
  }

  .favorite-button {
    min-height: 44px;
  }

  .loading-state {
    grid-template-columns: 1fr;
  }

  .skeleton,
  .skeleton-large {
    min-height: 400px;
  }

  footer {
    padding-inline: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
