@font-face {
  font-family: "Oswald";
  src: url("assets/oswald.ttf") format("truetype");
  font-weight: 200 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #22262a;
  --concrete: #d9d5c9;
  --paper: #f5f1e6;
  --teal: #2b4a46;
  --amber: #a6560d;
  --rule: #b9b4a4;

  --font-display: "Oswald", "Arial Narrow", sans-serif;
  --font-body: "Literata", Georgia, serif;

  --step-minus1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.2rem;
  --step-2: 1.5rem;
  --step-3: 2rem;
  --step-4: 2.9rem;
  --step-5: 3.8rem;

  --content-max: 74rem;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  background: var(--concrete);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--paper);
  color: var(--ink);
  padding: 0.75rem 1.25rem;
  z-index: 100;
  font-family: var(--font-display);
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--amber);
  border-radius: 1px;
}

button {
  font-family: var(--font-display);
  cursor: pointer;
}

/* ---------- Masthead ---------- */

.masthead {
  background: var(--teal);
  color: var(--paper);
  padding: 2.2rem 1.5rem 1.6rem;
}

.masthead-inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--step-5);
  letter-spacing: 0.01em;
  margin: 0;
  line-height: 0.95;
}

.tagline {
  font-family: var(--font-body);
  font-style: italic;
  font-size: var(--step-1);
  margin: 0.4rem 0 0;
  color: #d9e2df;
}

/* ---------- Controls ---------- */

.controls-bar {
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.controls-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1.1rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 1.1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field label {
  font-family: var(--font-display);
  font-size: var(--step-minus1);
  font-weight: 500;
}

.search-field {
  flex: 1 1 16rem;
}

.filter-field {
  flex: 0 1 12rem;
}

#search-input,
#filter-select {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--rule);
  background: #fff;
  color: var(--ink);
  border-radius: 2px;
}

#search-input {
  width: 100%;
}

.saved-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink);
  font-size: var(--step-minus1);
  font-weight: 500;
  padding: 0.55rem 0.9rem;
  border-radius: 2px;
  align-self: end;
}

.saved-toggle .icon {
  width: 16px;
  height: 16px;
  fill: var(--ink);
}

.saved-toggle[aria-pressed="true"] {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--paper);
}

.saved-toggle[aria-pressed="true"] .icon {
  fill: var(--paper);
}

/* ---------- Main list ---------- */

main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1.6rem 1.5rem 4rem;
}

.result-count {
  font-family: var(--font-display);
  font-size: var(--step-minus1);
  color: var(--teal);
  margin: 0 0 1rem;
}

.story-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.story-row {
  border-top: 1px solid var(--rule);
  padding: 1.4rem 0;
}

.story-row:last-child {
  border-bottom: 1px solid var(--rule);
}

.category-tag {
  font-family: var(--font-display);
  font-size: var(--step-minus1);
  color: var(--teal);
  font-weight: 500;
  display: block;
  margin-bottom: 0.3rem;
}

.open-item {
  display: block;
  text-align: left;
  background: none;
  border: none;
  padding: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-weight: 500;
  line-height: 1.15;
  margin: 0 0 0.4rem;
}

.open-item:hover {
  color: var(--amber);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.story-summary {
  font-family: var(--font-body);
  font-size: 1.02rem;
  max-width: 62ch;
  margin: 0 0 0.5rem;
  color: #40403b;
}

.story-meta {
  font-family: var(--font-body);
  font-style: italic;
  font-size: var(--step-minus1);
  color: #5a5952;
  margin: 0;
}

/* Featured row */

.story-row.featured {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr);
  gap: 1.75rem;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-top: 1px solid var(--rule);
  padding: 1.25rem;
  margin-bottom: 1.6rem;
  border-radius: 2px;
}

.story-row.featured .featured-image {
  width: 100%;
  height: 100%;
  min-height: 14rem;
  object-fit: cover;
  border-radius: 2px;
}

.story-row.featured .open-item {
  font-size: var(--step-4);
}

.story-row.featured .story-summary {
  font-size: 1.12rem;
}

/* ---------- Empty state ---------- */

.empty-state {
  padding: 3rem 1rem;
  text-align: center;
  border: 1px dashed var(--rule);
  border-radius: 2px;
}

.empty-state p {
  font-size: var(--step-1);
  max-width: 40ch;
  margin: 0 auto 1rem;
}

#empty-action {
  font-family: var(--font-display);
  background: var(--teal);
  color: var(--paper);
  border: none;
  padding: 0.65rem 1.3rem;
  font-size: var(--step-minus1);
  font-weight: 500;
  border-radius: 2px;
}

/* ---------- Footer ---------- */

.site-footer {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

.site-footer p {
  font-size: var(--step-minus1);
  color: #5a5952;
  max-width: 62ch;
}

/* ---------- Detail dialog ---------- */

.detail-dialog {
  padding: 0;
  border: none;
  margin: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  background: transparent;
  color: var(--ink);
}

.detail-dialog::backdrop {
  background: rgba(15, 18, 17, 0.55);
}

.detail-dialog[open] {
  display: flex;
  justify-content: flex-end;
}

.detail-inner {
  background: var(--paper);
  width: min(46rem, 100%);
  height: 100%;
  overflow-y: auto;
  padding: 1.25rem 1.5rem 4rem;
}

@media (prefers-reduced-motion: no-preference) {
  .detail-inner {
    animation: slide-in 0.28s ease-out;
  }
  .detail-dialog::backdrop {
    animation: fade-in 0.28s ease-out;
  }
}

@keyframes slide-in {
  from {
    transform: translateX(2.5rem);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.detail-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  background: var(--paper);
  padding-top: 0.5rem;
}

.back-btn,
.save-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-display);
  font-size: var(--step-minus1);
  font-weight: 500;
  border-radius: 2px;
  padding: 0.55rem 0.9rem;
}

.back-btn {
  background: none;
  border: 1px solid var(--rule);
  color: var(--ink);
}

.back-btn .icon {
  width: 16px;
  height: 16px;
}

.save-btn {
  background: none;
  border: 1px solid var(--amber);
  color: var(--amber);
}

.save-btn .icon {
  width: 16px;
  height: 16px;
  fill: var(--amber);
}

.save-btn[aria-pressed="true"] {
  background: var(--amber);
  color: var(--paper);
}

.save-btn[aria-pressed="true"] .icon {
  fill: var(--paper);
}

.detail-article .category-tag {
  margin-bottom: 0.5rem;
}

.detail-article h2 {
  font-family: var(--font-display);
  font-size: var(--step-4);
  line-height: 1.05;
  margin: 0 0 0.6rem;
}

.detail-article .story-meta {
  margin-bottom: 1.4rem;
}

.detail-image {
  width: 100%;
  max-height: 22rem;
  object-fit: cover;
  border-radius: 2px;
  margin-bottom: 1.6rem;
}

.detail-body {
  max-width: 62ch;
  font-size: 1.08rem;
  line-height: 1.7;
}

.detail-body p {
  margin: 0 0 1.1rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  .wordmark {
    font-size: var(--step-4);
  }

  .controls-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-field {
    flex: 1 1 auto;
  }

  .saved-toggle {
    align-self: flex-start;
  }

  .story-row.featured {
    grid-template-columns: 1fr;
  }

  .story-row.featured .open-item {
    font-size: var(--step-3);
  }

  .detail-inner {
    width: 100%;
    padding: 1rem 1.1rem 3rem;
  }

  .detail-article h2 {
    font-size: var(--step-3);
  }
}
