/* Foundations */

:root {
  color-scheme: dark;
  --bg: #050807;
  --surface: #0b100e;
  --surface-hover: #0e1512;
  --text: #e5dfd1;
  --text-soft: #c4c0b5;
  --muted: #918f86;
  --line: #26352d;
  --line-strong: #3e5c4b;
  --phosphor: #5ee783;
  --amber: #e0a64b;
  --signal-yellow: #e3ca62;
  --glow-soft: 0 0 12px rgba(94, 231, 131, 0.24);
  --glow-active: 0 0 16px rgba(94, 231, 131, 0.38);
  --body-mono: "IBM Plex Mono", monospace;
  --display-mono: "Space Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 18% -8%, rgba(94, 231, 131, 0.045), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: var(--body-mono);
  line-height: 1.5;
}

a {
  color: inherit;
}

/* Shared layout and accessibility */

.wrap {
  width: min(860px, calc(100% - 40px));
  margin: 0 auto;
}

.skip-link {
  position: fixed;
  z-index: 10;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.8rem;
  background: var(--phosphor);
  color: var(--bg);
  font-family: var(--body-mono);
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-180%);
}

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

/* Site header */

.site-header {
  padding: 3.25rem 0 2.5rem;
  border-bottom: 1px solid var(--line);
}

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

.site-title {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-family: var(--display-mono);
  font-size: clamp(1.8rem, 4.2vw, 2.65rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.055em;
}

.site-title a {
  color: var(--text);
  text-decoration-color: transparent;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition:
    color 160ms ease,
    text-decoration-color 160ms ease,
    text-shadow 160ms ease;
}

.site-title a:hover,
.site-title a:focus-visible {
  color: var(--phosphor);
  text-decoration-color: var(--phosphor);
  text-shadow: var(--glow-soft);
}

.site-title a:focus-visible {
  outline: 2px solid var(--phosphor);
  outline-offset: 5px;
}

.title-cursor {
  display: inline-block;
  width: 0.14em;
  height: 0.72em;
  margin-left: 0.16em;
  background: var(--phosphor);
  box-shadow: var(--glow-soft);
  opacity: 0.45;
  transform: translateY(0.04em);
}

.site-title a:hover .title-cursor,
.site-title a:focus-visible .title-cursor {
  animation: title-cursor-pulse 800ms steps(2, end) infinite;
  opacity: 1;
}

@keyframes title-cursor-pulse {
  50% {
    opacity: 0.3;
  }
}

.subtitle {
  max-width: 580px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(0.9rem, 2vw, 1rem);
  line-height: 1.7;
}

/* Catalogue controls */

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px 176px 92px;
  align-items: end;
  gap: 0.85rem;
  padding: 1.9rem 0;
  border-bottom: 1px solid var(--line);
}

.control label,
.control-label {
  display: block;
  margin-bottom: 0.65rem;
  color: var(--muted);
  font-family: var(--body-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.award-filter {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  gap: 1rem;
}

.award-filter .control-label {
  margin-bottom: 0;
}

.award-options {
  display: inline-flex;
}

.award-options button {
  min-height: 38px;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--body-mono);
  font-size: 0.75rem;
  cursor: pointer;
}

.award-options button + button {
  margin-left: -1px;
}

.award-options button:hover:not(:disabled),
.award-options button:focus-visible {
  position: relative;
  z-index: 1;
  border-color: var(--phosphor);
  color: var(--text);
}

.award-options button:focus-visible {
  outline: 2px solid var(--phosphor);
  outline-offset: 3px;
}

.award-options button[aria-pressed="true"] {
  position: relative;
  z-index: 1;
  border-color: var(--phosphor);
  color: var(--phosphor);
  background: rgba(94, 231, 131, 0.06);
}

.award-options button[data-award="nebula"][aria-pressed="true"] {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(224, 166, 75, 0.06);
}

.award-options button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.control input,
.control select {
  width: 100%;
  height: 47px;
  padding: 0 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  outline: 0;
  background: var(--surface);
  color: var(--text);
  font-family: var(--body-mono);
  font-size: 0.9rem;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.control select {
  padding-right: 2.75rem;
  appearance: none;
  cursor: pointer;
}

.control--select {
  position: relative;
}

.control--select::after {
  position: absolute;
  right: 1rem;
  bottom: 1.25rem;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 1px solid var(--phosphor);
  border-bottom: 1px solid var(--phosphor);
  content: "";
  pointer-events: none;
  transform: rotate(45deg);
  transform-origin: center;
}

.control input::placeholder {
  color: #74877f;
}

.control input:focus,
.control select:focus {
  border-color: var(--phosphor);
  box-shadow:
    0 0 0 1px rgba(94, 231, 131, 0.16),
    var(--glow-soft);
}

.reset-button {
  width: 92px;
  height: 47px;
  padding: 0 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  color: var(--phosphor);
  font-family: var(--body-mono);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
}

.reset-button:hover:not(:disabled),
.reset-button:focus-visible {
  border-color: var(--phosphor);
  box-shadow: var(--glow-soft);
}

.reset-button:focus-visible {
  outline: 2px solid var(--phosphor);
  outline-offset: 3px;
}

.reset-button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.45;
}

/* Catalogue layout and story cards */

.catalogue {
  padding: 2.35rem 0 4.5rem;
}

.catalogue-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.catalogue-heading h2 {
  margin-bottom: 0;
  font-family: var(--display-mono);
  font-size: 1.2rem;
  font-weight: 700;
}

#result-count {
  margin-bottom: 0;
  color: var(--muted);
  font-family: var(--body-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.story-list {
  display: grid;
  gap: 0.85rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.story-card {
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color 140ms ease, background-color 140ms ease;
}

.story-card:hover,
.story-card:focus-within {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.story-card--special-result {
  border-style: dashed;
  border-left: 3px solid var(--signal-yellow);
  background:
    linear-gradient(90deg, rgba(227, 202, 98, 0.045), transparent 24rem),
    var(--surface);
}

.story-card--special-result:hover,
.story-card--special-result:focus-within {
  border-left-color: var(--signal-yellow);
}

.award-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.award-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.15rem;
  font-family: var(--body-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1;
  text-decoration: none;
  text-transform: uppercase;
}

.award-badge::before {
  margin-right: 0.35rem;
  content: "[";
  opacity: 0.62;
}

.award-badge::after {
  margin-left: 0.35rem;
  content: "]";
  opacity: 0.62;
}

.award-badge__label {
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22rem;
}

.award-badge:hover .award-badge__label {
  text-shadow: var(--glow-active);
}

.award-badge:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 3px;
}

.award-badge:focus-visible .award-badge__label {
  text-shadow: var(--glow-active);
}

.award-badge--hugo {
  color: var(--phosphor);
}

.award-badge--nebula {
  color: var(--amber);
}

.result-warning {
  display: inline-grid;
  width: 1.35rem;
  height: 1.35rem;
  place-items: center;
  border: 1px solid var(--signal-yellow);
  color: var(--signal-yellow);
  font-family: var(--body-mono);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 0 10px rgba(227, 202, 98, 0.16);
}

.story-card h3 {
  max-width: 680px;
  margin-bottom: 0.4rem;
  font-family: var(--display-mono);
  font-size: clamp(1.12rem, 2.8vw, 1.4rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.025em;
}

.story-card--special-result h3 {
  margin-bottom: 0.95rem;
  color: var(--signal-yellow);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.95rem;
  font-size: 0.9rem;
}

.meta-author {
  color: var(--text-soft);
  font-weight: 500;
}

.meta-publication {
  color: var(--muted);
}

.meta-separator {
  color: var(--line-strong);
}

.links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.links a {
  color: var(--phosphor);
  font-family: var(--body-mono);
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
}

.links a::after {
  margin-left: 0.3rem;
  content: "↗";
}

.links a:hover {
  text-decoration: underline;
  text-underline-offset: 0.22rem;
  text-shadow: var(--glow-active);
}

.links a:focus-visible {
  outline: 2px solid var(--phosphor);
  outline-offset: 4px;
  text-shadow: var(--glow-active);
}

.links .read-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 128px;
  min-height: 44px;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line-strong);
  background: rgba(94, 231, 131, 0.035);
  font-family: var(--body-mono);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
}

.links .read-link:hover,
.links .read-link:focus-visible {
  border-color: var(--phosphor);
  text-decoration: none;
}

.read-action--unavailable {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  opacity: 0.72;
}

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

/* Catalogue status and pagination */

.empty,
.loading,
.error {
  padding: 1.4rem;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  background: var(--surface);
}

.error {
  border-color: #8d4b3c;
  color: #e5aa97;
}

.pagination {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.pagination--top {
  margin-top: 0;
  margin-bottom: 1rem;
  padding-top: 0;
  padding-bottom: 1rem;
  border-top: 0;
  border-bottom: 1px solid var(--line);
}

.pagination[hidden] {
  display: none;
}

.pagination button {
  min-width: 44px;
  min-height: 36px;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--body-mono);
  font-size: 0.75rem;
  cursor: pointer;
}

.pagination [data-page-action] {
  width: 84px;
}

.pagination button:hover:not(:disabled),
.pagination button:focus-visible {
  border-color: var(--phosphor);
  color: var(--phosphor);
}

.pagination button:focus-visible {
  outline: 2px solid var(--phosphor);
  outline-offset: 3px;
}

.pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.page-numbers {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.page-number[aria-current="page"] {
  border-color: var(--phosphor);
  color: var(--phosphor);
  background: rgba(94, 231, 131, 0.06);
}

.page-gap,
.page-status {
  color: var(--muted);
  font-family: var(--body-mono);
  font-size: 0.75rem;
}

.page-status {
  display: none;
  text-align: center;
}

/* Footer and About page */

.site-footer {
  padding: 2rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--body-mono);
  font-size: 0.75rem;
}

.site-footer .wrap {
  display: block;
  text-align: center;
}

.site-footer p {
  margin-bottom: 0;
}

.site-footer a {
  color: var(--muted);
  text-underline-offset: 0.2rem;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--phosphor);
}

.about-main {
  padding: 3rem 0 4.5rem;
}

.about-copy {
  max-width: 68ch;
}

.about-title {
  margin-bottom: 1rem;
  color: var(--phosphor);
  font-family: var(--body-mono);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.09em;
  text-shadow: var(--glow-soft);
  text-transform: uppercase;
}

.about-copy p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.8;
}

.about-copy p:last-child {
  margin-bottom: 0;
}

.about-main a {
  color: var(--phosphor);
  text-underline-offset: 0.22rem;
}

.about-main a:focus-visible {
  outline: 2px solid var(--phosphor);
  outline-offset: 4px;
}

/* Responsive layout */

@media (max-width: 600px) {
  .wrap {
    width: min(100% - 36px, 860px);
  }

  .site-header {
    padding: 2.6rem 0 2.15rem;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
    padding: 1.65rem 0;
  }

  .control--search,
  .reset-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .award-filter {
    display: block;
  }

  .award-filter .control-label {
    margin-bottom: 0.65rem;
  }

  .award-options {
    display: flex;
  }

  .award-options button {
    flex: 1;
  }

  .catalogue {
    padding: 2rem 0 3.5rem;
  }

  .story-card {
    padding: 1.15rem;
  }

  .award-badge {
    min-height: 40px;
    padding: 0.5rem 0.15rem;
  }

  .meta {
    display: block;
  }

  .meta span {
    display: block;
  }

  .meta .meta-separator {
    display: none;
  }

  .links {
    align-items: stretch;
    flex-direction: column;
    gap: 0.65rem;
    margin-top: 1rem;
  }

  .links a {
    min-height: 44px;
    padding: 0.75rem 0;
  }

  .links .read-action {
    width: 100%;
    justify-content: center;
    padding-right: 0.85rem;
    padding-left: 0.85rem;
  }

  .page-numbers {
    display: none;
  }

  .page-status {
    display: block;
  }

  .pagination {
    gap: 0.65rem;
    margin-top: 0.625rem;
    padding-top: 0.625rem;
  }

  .pagination--top {
    margin-top: 0;
    margin-bottom: 0.625rem;
    padding-top: 0;
    padding-bottom: 0.625rem;
  }

  .pagination button {
    min-height: 40px;
    padding: 0.45rem 0.75rem;
  }
}

@media (min-width: 601px) and (max-width: 820px) {
  .site-title {
    white-space: nowrap;
  }

  .controls {
    grid-template-columns: minmax(0, 1fr) 140px 168px;
  }

  .reset-button {
    grid-column: 1 / -1;
  }
}

@media (min-width: 700px) and (max-width: 820px) {
  .controls {
    grid-template-columns: minmax(0, 1fr) 130px 160px 92px;
    gap: 0.65rem;
  }

  .reset-button {
    grid-column: auto;
  }
}

@media (min-width: 821px) {
  .site-title {
    white-space: nowrap;
  }

  .story-card:has(> .links) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 176px;
    column-gap: 1.5rem;
  }

  .story-card:has(> .links) > .award-badges,
  .story-card:has(> .links) > h3,
  .story-card:has(> .links) > .meta {
    grid-column: 1;
  }

  .story-card:has(> .links) > .links {
    grid-row: 1 / 4;
    grid-column: 2;
    align-self: stretch;
    justify-content: center;
  }

  .story-card:has(> .links) .read-action {
    width: 152px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .control input,
  .control select,
  .story-card,
  .site-title a {
    transition: none;
  }

  .site-title a:hover .title-cursor,
  .site-title a:focus-visible .title-cursor {
    animation: none;
  }
}
