/* ==========================================================================
   In Passing — an independent journal of everyday city life
   Visual system: cool lichen paper, deep petrol ink, one sodium-amber signal.
   Type: Oswald (signage / structure) + Literata (reading).
   ========================================================================== */

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

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

:root {
  --paper: #e8ebe2;
  --panel: #dce0d2;
  --panel-2: #d2d8c8;
  --ink: #16302f;
  --ink-2: #40524e;
  --muted: #667671;
  --line: rgba(22, 48, 47, 0.24);
  --line-soft: rgba(22, 48, 47, 0.13);
  --accent: #d98a22;
  --accent-deep: #9a5c0d;
  --accent-tint: rgba(217, 138, 34, 0.16);
  --shadow: 0 1px 0 rgba(22, 48, 47, 0.06);

  --font-display: "Oswald", "Arial Narrow", system-ui, sans-serif;
  --font-read: "Literata", Georgia, "Times New Roman", serif;

  --measure: 68ch;
  --gutter: clamp(1.1rem, 4vw, 3.5rem);
  --max: 82rem;
}

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

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-read);
  font-size: 1rem;
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

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

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

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100%;
  z-index: 100;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  padding: 0.6rem 0.9rem;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 0.75rem;
}

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

.masthead {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.masthead__inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(1.4rem, 3.5vw, 2.6rem) var(--gutter) 0;
}

.masthead__line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 0.55rem;
}

.masthead__kicker,
.masthead__issue {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  color: var(--ink-2);
}

.masthead__issue {
  color: var(--muted);
  white-space: nowrap;
}

.masthead__title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(15rem, 22rem);
  align-items: end;
  gap: clamp(1rem, 4vw, 3rem);
  padding: clamp(1.4rem, 5vw, 3.2rem) 0 clamp(1.6rem, 4vw, 2.6rem);
}

.masthead__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(3.6rem, 13.5vw, 9.5rem);
  line-height: 0.84;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.masthead__standfirst {
  margin: 0 0 0.4rem;
  font-family: var(--font-read);
  font-size: 1.02rem;
  line-height: 1.65;
  color: var(--ink-2);
  max-width: 30ch;
}

/* Issue skyline — the one bold move. Bar height = reading time. */

.skyline {
  border-top: 1px solid var(--line);
  padding: 0.75rem 0 0;
}

.skyline__head {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--muted);
}

.skyline__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: flex-end;
  gap: clamp(0.4rem, 1.4vw, 1.1rem);
  height: clamp(74px, 9.5vw, 132px);
  position: relative;
}

.skyline__list::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--ink);
}

.skyline__item {
  flex: 1 1 0;
  align-self: stretch;
  height: 100%;
  display: flex;
  align-items: flex-end;
  min-width: 0;
}

.skyline__bar {
  position: relative;
  width: 100%;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: var(--ink);
  height: var(--h, 50%);
  transition: background-color 0.18s ease, transform 0.18s ease;
  border-radius: 2px 2px 0 0;
}

.skyline__bar:hover,
.skyline__bar:focus-visible {
  background: var(--accent);
  transform: translateY(-3px);
}

.skyline__label {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.72rem;
  line-height: 1.25;
  padding: 0.35rem 0.5rem;
  white-space: nowrap;
  max-width: 15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 5;
}

.skyline__item:last-child .skyline__label {
  left: auto;
  right: 0;
  transform: none;
}

.skyline__bar:hover .skyline__label,
.skyline__bar:focus-visible .skyline__label {
  opacity: 1;
}

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

.controls {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(232, 235, 226, 0.94);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  border-bottom: 1px solid var(--line);
}

.controls__inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.7rem var(--gutter);
  display: flex;
  align-items: end;
  gap: clamp(0.75rem, 2.5vw, 1.75rem);
  flex-wrap: wrap;
}

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

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

.field--select {
  flex: 0 0 auto;
}

.field--saved {
  flex: 0 0 auto;
}

.field__label {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.76rem;
  color: var(--muted);
}

.field__input,
.field__select {
  font-family: var(--font-read);
  font-size: 0.95rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.42rem 0.55rem;
  min-height: 2.35rem;
}

.field__input::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

.field__input:focus,
.field__select:focus {
  border-color: var(--ink);
}

.saved-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.86rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.42rem 0.7rem;
  min-height: 2.35rem;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease;
}

.saved-toggle svg {
  color: var(--muted);
}

.saved-toggle:hover {
  border-color: var(--ink);
}

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

.saved-toggle[aria-pressed="true"] svg {
  color: var(--accent);
}

.controls__count {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter) 0.55rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.76rem;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Story index
   -------------------------------------------------------------------------- */

.page {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) var(--gutter) clamp(3rem, 8vw, 6rem);
}

.index {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.item {
  border-bottom: 1px solid var(--line);
}

.item__article {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr) auto;
  gap: clamp(0.9rem, 2.5vw, 2.25rem);
  padding: clamp(1.3rem, 3vw, 2.1rem) 0;
  align-items: start;
}

.item__stamp {
  align-self: start;
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--ink-2);
  background: var(--panel);
  border-left: 3px solid var(--ink);
  padding: 0.22rem 0.5rem 0.24rem;
  border-radius: 0 2px 2px 0;
  white-space: nowrap;
  justify-self: start;
}

.item__main {
  min-width: 0;
}

.item__title {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.35rem, 2.9vw, 2.15rem);
  line-height: 1.02;
  letter-spacing: -0.012em;
}

.open-item {
  font: inherit;
  color: inherit;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-underline-offset: 0.18em;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 2px;
  transition: text-decoration-color 0.16s ease, color 0.16s ease;
}

.open-item:hover,
.open-item:focus-visible {
  text-decoration-color: var(--accent);
}

.item__summary {
  margin: 0 0 0.8rem;
  font-family: var(--font-read);
  font-size: 1.02rem;
  line-height: 1.62;
  color: var(--ink-2);
  max-width: 58ch;
}

.item__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--muted);
}

.item__author {
  color: var(--ink-2);
}

.item__time {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

/* Reading-time meter: one tick per minute. */
.ticks {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 0.85rem;
}

.ticks i {
  display: block;
  width: 2px;
  height: 55%;
  background: var(--muted);
  opacity: 0.65;
}

.ticks i:nth-child(2n) {
  height: 100%;
}

.item__saved {
  align-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.74rem;
  color: var(--accent-deep);
  white-space: nowrap;
}

.item__saved svg {
  color: var(--accent);
}

/* Lead entry: the first visible story gets a little more room. */
.item.is-lead .item__article {
  padding-top: clamp(1.6rem, 4vw, 2.8rem);
  padding-bottom: clamp(1.6rem, 4vw, 2.8rem);
}

.item.is-lead .item__title {
  font-size: clamp(1.7rem, 4.4vw, 3.4rem);
  line-height: 0.98;
}

.item.is-lead .item__summary {
  font-size: 1.12rem;
  max-width: 52ch;
}

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

.empty-state {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: clamp(1.6rem, 5vw, 3rem);
  max-width: 40rem;
}

.empty-state__title {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.5rem;
}

.empty-state__text {
  margin: 0 0 1.2rem;
  font-family: var(--font-read);
  color: var(--ink-2);
  max-width: 46ch;
}

.button {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.88rem;
  border-radius: 2px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
}

.button--quiet {
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.button--quiet:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
}

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

.footer {
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.footer__inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 2.5rem) var(--gutter);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.6rem 2.5rem;
  align-items: start;
}

.footer__name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
}

.footer__note {
  margin: 0;
  font-family: var(--font-read);
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Detail view (native dialog)
   -------------------------------------------------------------------------- */

.detail {
  width: min(58rem, calc(100vw - 2rem));
  max-width: 100%;
  max-height: min(92dvh, 100%);
  padding: 0;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
  overflow: auto;
  overscroll-behavior: contain;
}

.detail::backdrop {
  background: rgba(22, 48, 47, 0.55);
}

.detail[open] {
  animation: detail-in 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes detail-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

.detail__bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem var(--gutter);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.detail__eyebrow {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.6rem;
  align-items: baseline;
}

.detail__eyebrow-name {
  color: var(--ink);
}

.detail__eyebrow-cat {
  color: var(--ink-2);
}

.detail__close {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease,
    border-color 0.15s ease;
}

.detail__close:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.detail__media {
  margin: 0;
  position: relative;
  background: var(--ink);
  isolation: isolate;
  aspect-ratio: 16 / 8;
  overflow: hidden;
}

.detail__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.06) brightness(1.03);
  mix-blend-mode: screen;
  opacity: 0.88;
}

.detail__caption {
  position: absolute;
  left: 0;
  bottom: 0;
  margin: 0;
  padding: 0.3rem 0.55rem;
  background: rgba(22, 48, 47, 0.82);
  color: var(--paper);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.68rem;
}

.detail__article {
  padding: clamp(1.5rem, 4vw, 2.8rem) var(--gutter) 1rem;
}

.detail__category {
  margin: 0 0 0.6rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--accent-deep);
}

.detail__title {
  margin: 0 0 0.7rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 6vw, 3.6rem);
  line-height: 0.98;
  letter-spacing: -0.02em;
  max-width: 24ch;
}

.detail__summary {
  margin: 0 0 0.9rem;
  font-family: var(--font-read);
  font-size: 1.18rem;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 54ch;
}

.detail__meta {
  margin: 0 0 1.8rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.1rem;
}

.detail__body {
  max-width: var(--measure);
}

.detail__body p {
  margin: 0 0 1.15rem;
  font-family: var(--font-read);
  font-size: 1.14rem;
  line-height: 1.78;
  color: var(--ink);
}

.detail__actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 0.8rem var(--gutter);
  background: var(--paper);
  border-top: 1px solid var(--line);
}

.save-item {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.9rem;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 2px;
  padding: 0.6rem 1.05rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease,
    border-color 0.15s ease;
}

.save-item:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
}

.save-item[aria-pressed="true"] {
  background: transparent;
  color: var(--accent-deep);
  border-color: var(--accent-deep);
}

.save-item[aria-pressed="true"]:hover {
  background: var(--accent-tint);
}

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

@media (max-width: 56rem) {
  .masthead__title-row {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 1rem;
  }

  .masthead__standfirst {
    max-width: 40ch;
  }

  .item__article {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .item__stamp {
    justify-self: start;
  }

  .item__saved {
    position: static;
  }

  .footer__inner {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 34rem) {
  .controls__inner {
    gap: 0.6rem 0.75rem;
  }

  .field--search {
    flex: 1 1 100%;
  }

  .field--select,
  .field--saved {
    flex: 1 1 auto;
  }

  .field__select,
  .saved-toggle {
    width: 100%;
  }

  .skyline__list {
    gap: 0.3rem;
  }

  .detail {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .detail__media {
    aspect-ratio: 16 / 10;
  }
}

@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;
  }
}
