/* ==========================================================================
   Crosstown — an everyday city journal
   Identity: the blue hour. Browsing is the city after dark; opening a story
   switches a light on into a warm paper reading surface.
   ========================================================================== */

@font-face {
  font-family: "Space Grotesk";
  src: url("assets/space-grotesk.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-weight: 200 700;
  font-display: swap;
}

:root {
  /* Night field */
  --night: #0d1622;
  --night-2: #131e2c;
  --night-3: #1b2838;
  --glow: #24384e;

  --paper: #f2ede2;
  --paper-2: #e6dfd0;
  --ink: #1a1a17;
  --ink-soft: #514c43;
  --ink-faint: #6f6759;

  --text: #ece7db;
  --text-soft: #9aa8b6;
  --text-faint: #8593a2;

  --amber: #f2b23a;
  --amber-deep: #b97d15;
  --line: rgba(236, 231, 219, 0.14);
  --line-strong: rgba(236, 231, 219, 0.26);

  --c-culture: #dd9a54;
  --c-food: #cf6a57;
  --c-movement: #6fa8c2;
  --c-people: #b98cae;
  --c-places: #7fae86;

  --sans: "Space Grotesk", "Avenir Next", system-ui, system-ui, sans-serif;
  --serif: "Literata", Georgia, "Times New Roman", serif;

  --measure: 68ch;
  --radius: 3px;
}

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--night);
  background-image:
    radial-gradient(
      ellipse 120% 55% at 50% -12%,
      var(--glow) 0%,
      rgba(36, 56, 78, 0) 62%
    ),
    linear-gradient(180deg, #0b131d 0%, var(--night) 40%, #0a1119 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
  border-radius: 2px;
}

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

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 40;
  padding: 10px 16px;
  background: var(--amber);
  color: #1a1206;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius);
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 12px;
}

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

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 19, 29, 0.86);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
}

.masthead__inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 28px 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.masthead__brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.mark {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, 6px);
  grid-auto-rows: 6px;
  gap: 3px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
}
.mark span {
  background: rgba(236, 231, 219, 0.22);
  border-radius: 1px;
}
.mark .mark__lit {
  background: var(--amber);
  box-shadow: 0 0 10px rgba(242, 178, 58, 0.7);
}

.wordmark {
  margin: 0;
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}
.tagline {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 0.8rem;
  letter-spacing: 0.01em;
}

.vitals {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-faint);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.vitals__rule {
  width: 34px;
  height: 1px;
  background: var(--line-strong);
}

.masthead__rule {
  max-width: 1240px;
  margin: 0 auto;
  height: 1px;
  background: linear-gradient(
    90deg,
    var(--amber) 0%,
    var(--line) 14%,
    var(--line) 100%
  );
}

/* Controls */
.controls {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 28px 16px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 190px auto;
  gap: 18px;
  align-items: end;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field__label {
  font-size: 0.8rem;
  color: var(--text-soft);
}
.field__input,
.field__select {
  position: relative;
  display: flex;
  align-items: center;
}
.field__icon {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--text-faint);
  stroke-width: 1.6;
  pointer-events: none;
}
#search {
  width: 100%;
  padding: 11px 12px 11px 38px;
  background: var(--night-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}
#search::placeholder {
  color: var(--text-faint);
}
#search:hover {
  border-color: var(--line-strong);
}
#search:focus {
  border-color: var(--amber);
  background: var(--night-3);
}
#search::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

#filter {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding: 11px 36px 11px 13px;
  background: var(--night-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}
#filter:hover {
  border-color: var(--line-strong);
}
#filter:focus {
  border-color: var(--amber);
  background: var(--night-3);
}
.field__chevron {
  position: absolute;
  right: 13px;
  width: 12px;
  height: 8px;
  fill: none;
  stroke: var(--text-soft);
  stroke-width: 1.6;
  pointer-events: none;
}
#filter option {
  color: #10161f;
}

.saved-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 15px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text-soft);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.saved-toggle:hover {
  color: var(--text);
  border-color: var(--text-soft);
}
.saved-toggle__heart svg {
  width: 17px;
  height: 17px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
}
.saved-toggle__count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(236, 231, 219, 0.1);
  color: var(--text-soft);
  font-size: 0.74rem;
  text-align: center;
}
.saved-toggle[aria-pressed="true"] {
  color: var(--night);
  background: var(--amber);
  border-color: var(--amber);
}
.saved-toggle[aria-pressed="true"] .saved-toggle__heart svg {
  fill: var(--night);
}
.saved-toggle[aria-pressed="true"] .saved-toggle__count {
  background: rgba(13, 22, 34, 0.22);
  color: var(--night);
}

/* --------------------------------------------------------------------------
   Page + intro
   -------------------------------------------------------------------------- */

.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 46px 28px 80px;
}

.intro {
  max-width: 760px;
  margin-bottom: 42px;
}
.intro__standfirst {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.35rem, 2.6vw, 1.85rem);
  line-height: 1.4;
  font-weight: 400;
  color: var(--text);
  text-wrap: balance;
}
.intro__count {
  margin: 18px 0 0;
  color: var(--text-faint);
  font-size: 0.88rem;
}

.layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 64px;
  align-items: start;
}

/* Rail */
.rail {
  position: sticky;
  top: 168px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.rail__title {
  margin: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 0.95rem;
  font-weight: 500;
}
.rail__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rail__list button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 4px;
  background: none;
  border: 0;
  border-left: 2px solid transparent;
  color: var(--text-soft);
  font-size: 0.9rem;
  text-align: left;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.rail__list button:hover {
  color: var(--text);
}
.rail__list button[aria-current="true"] {
  color: var(--text);
  border-left-color: var(--amber);
  padding-left: 11px;
}
.rail__dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 2px;
  background: var(--dot, var(--text-faint));
}
.rail__list .rail__count {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}
.rail__note {
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 0.76rem;
  line-height: 1.55;
}
.rail__note-title {
  margin: 0 0 5px;
  color: var(--text-soft);
  font-size: 0.82rem;
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   Story list
   -------------------------------------------------------------------------- */

.stories {
  scroll-margin-top: 24px;
}

.stories__list {
  display: flex;
  flex-direction: column;
}

.story {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px;
  gap: 28px;
  padding: 26px 0;
  border-top: 1px solid var(--line);
  transition: background 0.18s ease;
}
.story:first-child {
  border-top: 0;
  padding-top: 6px;
}
.story:hover {
  background: linear-gradient(
    90deg,
    rgba(242, 178, 58, 0.06),
    rgba(242, 178, 58, 0)
  );
}
.story:focus-within {
  background: linear-gradient(
    90deg,
    rgba(242, 178, 58, 0.08),
    rgba(242, 178, 58, 0)
  );
}

.story__open {
  position: absolute;
  inset: 0;
  z-index: 1;
  border: 0;
  background: none;
  padding: 0 0 0 0;
  cursor: pointer;
}
.story__open:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 4px;
  border-radius: var(--radius);
}

.story__text {
  min-width: 0;
}
.story__kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--text-soft);
  font-size: 0.84rem;
  font-weight: 500;
}
.story__kicker .rail__dot {
  width: 9px;
  height: 9px;
}
.story__title {
  margin: 0 0 9px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.3rem, 2.1vw, 1.62rem);
  line-height: 1.22;
  letter-spacing: -0.01em;
  color: var(--text);
  text-wrap: balance;
}
.story__summary {
  margin: 0;
  max-width: 54ch;
  color: var(--text-soft);
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.55;
}
.story__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-top: 15px;
  color: var(--text-faint);
  font-size: 0.78rem;
}
.story__author {
  color: var(--text-soft);
}
.story__read {
  font-variant-numeric: tabular-nums;
}

.story__media {
  align-self: start;
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--night-3);
}
.story__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.3) contrast(1.05) brightness(0.9);
  transition: transform 0.5s ease, filter 0.5s ease;
}
.story__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
      180deg,
      rgba(13, 22, 34, 0),
      rgba(13, 22, 34, 0.42)
    ),
    linear-gradient(120deg, rgba(36, 56, 78, 0.45), rgba(242, 178, 58, 0.1));
  mix-blend-mode: multiply;
}
.story:hover .story__media img {
  transform: scale(1.04);
  filter: grayscale(0.1) contrast(1.05) brightness(0.92);
}

/* Featured (first visible) story */
.story--featured {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 40px;
  padding: 8px 0 34px;
  border-top: 0;
}
.story--featured .story__media {
  order: 2;
  aspect-ratio: 16 / 11;
}
.story--featured .story__text {
  order: 1;
  align-self: center;
}
.story--featured .story__title {
  font-size: clamp(1.85rem, 4vw, 2.9rem);
  line-height: 1.08;
  font-weight: 500;
  margin-bottom: 14px;
}
.story--featured .story__summary {
  font-size: 1.1rem;
  max-width: 46ch;
}

/* Empty state */
.empty-state {
  margin-top: 8px;
  padding: 56px 32px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
}
.empty-state__mark {
  display: block;
  width: 40px;
  height: 40px;
  margin: 0 auto 18px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  position: relative;
}
.empty-state__mark::after {
  content: "";
  position: absolute;
  inset: 13px;
  background: var(--amber);
  border-radius: 2px;
  box-shadow: 0 0 14px rgba(242, 178, 58, 0.6);
}
.empty-state__title {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 500;
}
.empty-state__body {
  margin: 0 auto 22px;
  max-width: 42ch;
  color: var(--text-soft);
}
.empty-state__reset {
  padding: 10px 18px;
  background: var(--amber);
  color: #1a1206;
  border: 0;
  border-radius: var(--radius);
  font-weight: 600;
}
.empty-state__reset:hover {
  background: #f7c45c;
}

/* --------------------------------------------------------------------------
   Reader (detail)
   -------------------------------------------------------------------------- */

.reader {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}
.reader::backdrop {
  background: rgba(7, 11, 17, 0.72);
  backdrop-filter: blur(3px);
}
.reader__surface {
  min-height: 100%;
  background-color: var(--paper);
  background-image: linear-gradient(
    180deg,
    #f6f2e8 0%,
    var(--paper) 30%,
    var(--paper-2) 100%
  );
  color: var(--ink);
}
.reader[open] .reader__surface {
  animation: reader-in 0.34s cubic-bezier(0.22, 0.8, 0.3, 1) both;
}
@keyframes reader-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.reader__bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 28px;
  background: rgba(242, 237, 226, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(26, 26, 23, 0.1);
}
.reader__close {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 4px;
  background: none;
  border: 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 500;
}
.reader__close:hover {
  color: var(--ink);
}
.reader__close svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.save-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  background: transparent;
  border: 1px solid rgba(26, 26, 23, 0.28);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.save-item:hover {
  border-color: var(--ink);
}
.save-item__heart svg {
  width: 16px;
  height: 16px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
}
.save-item[aria-pressed="true"] {
  background: var(--amber);
  border-color: var(--amber-deep);
  color: #21160a;
}
.save-item[aria-pressed="true"] .save-item__heart svg {
  fill: #21160a;
}

.reader__article {
  max-width: 720px;
  margin: 0 auto;
  padding: 52px 28px 120px;
}
.reader__kicker {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 500;
}
.reader__kicker .rail__dot {
  width: 9px;
  height: 9px;
}
.reader__title {
  margin: 0 0 18px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 5.4vw, 3.2rem);
  line-height: 1.08;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.reader__byline {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 16px;
  padding-bottom: 26px;
  border-bottom: 1px solid rgba(26, 26, 23, 0.16);
  margin-bottom: 30px;
  color: var(--ink-soft);
  font-size: 0.88rem;
}
.reader__byline .reader__author {
  color: var(--ink);
  font-weight: 500;
}
.reader__figure {
  margin: 0 0 34px;
}
.reader__figure img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius);
  filter: grayscale(0.3) contrast(1.02) brightness(0.96);
}
.reader__caption {
  margin-top: 9px;
  color: var(--ink-faint);
  font-size: 0.76rem;
  font-style: italic;
}
.reader__standfirst {
  margin: 0 0 30px;
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2.4vw, 1.4rem);
  line-height: 1.5;
  color: var(--ink);
}
.reader__body p {
  margin: 0 0 1.35em;
  font-family: var(--serif);
  font-size: clamp(1.05rem, 1.5vw, 1.16rem);
  line-height: 1.72;
  color: #24231e;
}
.reader__body p:first-of-type::first-letter {
  float: left;
  font-size: 3.3em;
  line-height: 0.82;
  padding: 0.06em 0.1em 0 0;
  font-weight: 500;
  color: var(--ink);
}
.reader__end {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid rgba(26, 26, 23, 0.16);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.reader__end-note {
  color: var(--ink-faint);
  font-size: 0.82rem;
}
.reader__end-nav {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 4px;
  background: none;
  border: 0;
  color: var(--ink);
  font-weight: 500;
}
.reader__end-nav svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}
.reader__end-nav:hover {
  color: var(--amber-deep);
}

/* Loading / error */
.status {
  padding: 60px 0;
  color: var(--text-soft);
}

/* --------------------------------------------------------------------------
   Colophon
   -------------------------------------------------------------------------- */

.colophon {
  border-top: 1px solid var(--line);
  padding: 34px 28px 54px;
  max-width: 1240px;
  margin: 0 auto;
}
.colophon__name {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 600;
}
.colophon__note {
  margin: 0;
  max-width: 52ch;
  color: var(--text-faint);
  font-size: 0.82rem;
}

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

@media (max-width: 940px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 26px;
  }
  .rail {
    position: static;
    order: 2;
    margin-top: 34px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
  }
  .rail__list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }
  .rail__list li {
    flex: 0 0 auto;
  }
  .rail__list button {
    border-left: 0;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 12px;
  }
  .rail__list button[aria-current="true"] {
    padding-left: 12px;
    border-color: var(--amber);
  }
  .rail__note {
    display: none;
  }
}

@media (max-width: 760px) {
  .masthead__inner {
    padding: 14px 18px 10px;
  }
  .vitals {
    display: none;
  }
  .controls {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 12px 18px 14px;
  }
  .masthead {
    position: static;
  }
  .field--search,
  .field--filter,
  .saved-toggle {
    grid-column: auto;
  }
  .saved-toggle {
    justify-content: center;
  }
  .page {
    padding: 30px 18px 64px;
  }
  .intro {
    margin-bottom: 26px;
  }
  .story,
  .story--featured {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    padding: 22px 0;
  }
  .story--featured {
    padding-top: 4px;
  }
  .story__media,
  .story--featured .story__media {
    order: -1;
    aspect-ratio: 16 / 9;
  }
  .story--featured .story__title {
    font-size: clamp(1.5rem, 7vw, 2rem);
  }
  .reader__bar {
    padding: 12px 18px;
  }
  .reader__article {
    padding: 34px 20px 90px;
  }
  .reader__close span {
    display: inline;
  }
}

@media (max-width: 380px) {
  .masthead__inner {
    padding-left: 14px;
    padding-right: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .story:hover .story__media img {
    transform: none;
  }
}
