/* ==========================================================================
   F2 — Journey view & Header ring styles (tokens only, calm & art-first)
   ========================================================================== */

/* ---------------------------------------------------------------------------
   Header progress ring (#header-progress)
   --------------------------------------------------------------------------- */
.jr {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 32px;
  padding: 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface-1);
  color: var(--text-2);
  font-size: var(--fs-12);
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  flex: none;
  transition: background-color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}

.jr:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text-1);
}

.jr:active {
  transform: translateY(0.5px);
}

.jr:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.jr[aria-current="page"] {
  border-color: var(--accent);
  color: var(--text-1);
  background: var(--surface-2);
}

.jr__ring {
  display: block;
  flex: none;
}

.jr__track {
  fill: none;
  stroke: var(--surface-3);
}

.jr__value {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dasharray var(--dur-base) var(--ease);
}

.jr__count {
  display: inline-flex;
  align-items: baseline;
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-tight);
}

.jr__seen {
  color: var(--text-1);
  font-weight: var(--fw-semibold);
}

.jr__total {
  color: var(--text-3);
}

/* Placeholder shimmer while data loads */
.jr--placeholder {
  pointer-events: none;
  opacity: 0.6;
}

.jr__dot {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
}

.jr__bar {
  width: 44px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
}

/* Milestone celebration pulse */
.jr.is-celebrating {
  animation: jr-pulse 1.4s var(--ease) 1;
}

@keyframes jr-pulse {
  0% { transform: scale(1); border-color: var(--border); box-shadow: none; }
  35% { transform: scale(1.08); border-color: var(--accent); box-shadow: 0 0 16px var(--accent-soft); }
  70% { transform: scale(1.02); border-color: var(--accent); }
  100% { transform: scale(1); border-color: var(--border); box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  .jr.is-celebrating {
    animation: none;
  }
  .jn-ring.is-entering .jn-ring__value {
    animation: none;
  }
  .jw-cell.is-new {
    animation: none;
  }
  .jn-ring__value,
  .jn-track::after,
  .jn-bar__fill,
  .jw-cell {
    transition: none !important;
  }
}

/* Mobile compact ring */
@media (max-width: 899px), (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  .jr {
    min-height: 44px;
    min-width: 44px;
    padding: 0 8px 0 6px;
    gap: 4px;
  }
  .jr__total {
    display: none;
  }
}

/* ---------------------------------------------------------------------------
   Journey View (?view=journey)
   --------------------------------------------------------------------------- */
.jn {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background: var(--bg);
  color: var(--text-1);
}

.jn-header {
  position: sticky;
  top: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--filterbar-h);
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  backdrop-filter: var(--blur-backdrop);
  -webkit-backdrop-filter: var(--blur-backdrop);
  z-index: var(--z-sticky);
}

.jn-header__title {
  font-size: var(--fs-16);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-tight);
  margin: 0;
  color: var(--text-1);
}

.jn-header__spacer {
  flex: 1;
}

.jn-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6) var(--space-16);
}

/* Hero card with large ring */
.jn-hero {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  padding: var(--space-8);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-popover);
  position: relative;
  overflow: hidden;
}

.jn-hero::before {
  content: '';
  position: absolute;
  top: -80px;
  right: -80px;
  width: 260px;
  height: 260px;
  border-radius: var(--radius-full);
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 70%);
  pointer-events: none;
}

.jn-ring {
  position: relative;
  width: 196px;
  height: 196px;
  flex: none;
}

.jn-ring__svg {
  width: 100%;
  height: 100%;
  display: block;
}

.jn-ring__track {
  fill: none;
  stroke: var(--surface-2);
}

.jn-ring__value {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dasharray 0.8s var(--ease);
}

.jn-ring.is-entering .jn-ring__value {
  animation: jn-ring-enter 1s var(--ease) forwards;
}

@keyframes jn-ring-enter {
  from {
    stroke-dashoffset: var(--jn-c, 578);
  }
  to {
    stroke-dashoffset: 0;
  }
}

.jn-ring__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.jn-ring__pct {
  font-size: var(--fs-40);
  line-height: 1;
  font-weight: var(--fw-bold);
  color: var(--text-1);
  letter-spacing: var(--tracking-display);
}

.jn-ring__sign {
  font-size: var(--fs-20);
  font-weight: var(--fw-medium);
  color: var(--text-3);
  margin-left: 2px;
}

.jn-ring__caption {
  font-size: var(--fs-12);
  color: var(--text-3);
  letter-spacing: 0.02em;
  margin-top: 4px;
}

.jn-hero__text {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
}

.jn-eyebrow {
  font-size: var(--fs-12);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.02em;
  color: var(--text-2);
  margin: 0;
}

.jn-hero__title {
  font-size: var(--fs-28);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--text-1);
  margin: 0;
  line-height: 1.2;
}

.jn-hero__sub {
  font-size: var(--fs-16);
  color: var(--text-2);
  margin: 0;
  line-height: 1.4;
}

.jn-hero__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------------------
   Milestone Track
   --------------------------------------------------------------------------- */
.jn-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.jn-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.jn-section__hint {
  font-size: var(--fs-14);
  color: var(--text-3);
  margin: 0;
}

.jn-miles {
  overflow-x: auto;
  padding: var(--space-4) 0;
  margin: 0 calc(-1 * var(--space-2));
  -webkit-overflow-scrolling: touch;
}

.jn-track {
  list-style: none;
  margin: 0;
  padding: 0 var(--space-6);
  display: flex;
  justify-content: space-between;
  position: relative;
  min-width: 580px;
}

/* Connecting bar behind nodes */
.jn-track::before {
  content: '';
  position: absolute;
  top: 14px;
  left: var(--space-8);
  right: var(--space-8);
  height: 3px;
  background: var(--surface-3);
  border-radius: var(--radius-full);
}

.jn-track::after {
  content: '';
  position: absolute;
  top: 14px;
  left: var(--space-8);
  width: calc((100% - 2 * var(--space-8)) * var(--jn-fill, 0));
  height: 3px;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width 0.6s var(--ease);
}

.jn-mile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  text-align: center;
  position: relative;
  z-index: 1;
  min-width: 68px;
}

.jn-mile__dot {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-accent);
  transition: all var(--dur-base) var(--ease);
}

.jn-mile.is-reached .jn-mile__dot {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.jn-mile.is-next .jn-mile__dot {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface-2);
}

.jn-mile__n {
  font-size: var(--fs-14);
  font-weight: var(--fw-semibold);
  color: var(--text-2);
}

.jn-mile.is-reached .jn-mile__n {
  color: var(--text-1);
}

.jn-mile__date {
  font-size: var(--fs-12);
  color: var(--text-3);
  min-height: 1rem;
}

/* ---------------------------------------------------------------------------
   Stats Grid
   --------------------------------------------------------------------------- */
.jn-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
}

.jn-stat {
  padding: var(--space-4) var(--space-6);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.jn-stat__label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  color: var(--text-3);
  letter-spacing: 0.02em;
  margin: 0;
}

.jn-stat__value {
  font-size: var(--fs-28);
  font-weight: var(--fw-bold);
  color: var(--text-1);
  margin: 0;
  line-height: 1.2;
}

.jn-stat__unit {
  font-size: var(--fs-16);
  font-weight: var(--fw-medium);
  color: var(--text-2);
  margin-left: 2px;
}

.jn-stat__sub {
  font-size: var(--fs-12);
  color: var(--text-3);
  margin: 0;
}

.jn-stat--chart {
  grid-column: span 2;
}

.jn-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 68px;
  padding: var(--space-2) 0;
  width: 100%;
}

.jn-bar {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease);
}

.jn-bar:hover {
  background: var(--surface-3);
}

.jn-bar__fill {
  width: 100%;
  height: calc(var(--p, 0) * 100%);
  background: var(--text-3);
  border-radius: 2px;
  min-height: 2px;
  transition: height var(--dur-base) var(--ease);
}

.jn-bar.is-top .jn-bar__fill {
  background: var(--accent);
}

.jn-bar:hover .jn-bar__fill {
  filter: brightness(1.2);
}

.jn-bars__axis {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-12);
  color: var(--text-3);
}

/* ---------------------------------------------------------------------------
   Next up picks
   --------------------------------------------------------------------------- */
.jn-next {
  position: relative;
  min-height: 200px;
}

.jn-next .card {
  content-visibility: visible;
}

/* ---------------------------------------------------------------------------
   The Wall (1,244 book films)
   --------------------------------------------------------------------------- */
.jw {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.jw-legend {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--fs-12);
  color: var(--text-3);
}

.jw-legend__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.jw-legend__swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.jw-legend__swatch.is-seen {
  background: color-mix(in srgb, var(--accent) 45%, var(--surface-3));
  border-color: color-mix(in srgb, var(--accent) 65%, transparent);
}

.jw-wall {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-6);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

.jw-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  content-visibility: visible;
}

.jw-row__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--fs-14);
}

.jw-row__decade {
  font-weight: var(--fw-semibold);
  color: var(--text-1);
}

.jw-row__count {
  font-size: var(--fs-12);
  color: var(--text-3);
}

.jw-row__seen {
  font-weight: var(--fw-semibold);
  color: var(--text-1);
}

.jw-cells {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
  gap: 4px;
}

.jw-cell {
  aspect-ratio: 2 / 3;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: transform var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}

.jw-cell:hover {
  transform: scale(1.2);
  z-index: 2;
  border-color: var(--border-strong);
  box-shadow: var(--shadow-hover);
}

.jw-cell:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  z-index: 3;
  transform: scale(1.15);
}

.jw-cell.is-seen {
  background: color-mix(in srgb, var(--accent) 22%, var(--surface-3));
  border-color: color-mix(in srgb, var(--accent) 48%, var(--border-strong));
}

.jw-cell.is-bare {
  background: color-mix(in srgb, var(--accent) 32%, var(--surface-3));
}

.jw-cell.is-selected {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
  z-index: 3;
}

.jw-cell__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.jw-cell.is-new {
  animation: jw-cell-flash 1s var(--ease) 1;
}

@keyframes jw-cell-flash {
  0% { transform: scale(1); filter: brightness(1.6); }
  50% { transform: scale(1.25); filter: brightness(1.8); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* Desktop: unseen cells don't show img, keeping desktop visually identical */
@media (min-width: 900px) {
  .jw-cell.is-unseen .jw-cell__img {
    display: none;
  }
  .jn-hero__next-bar {
    display: none;
  }
}

/* Next milestone bar */
.jn-bar-progress {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
  max-width: 320px;
  margin: var(--space-2) auto 0;
}

.jn-bar-progress__label {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-12);
  color: var(--text-2);
  font-weight: var(--fw-medium);
}

.jn-bar-progress__track {
  height: 6px;
  background: var(--surface-3);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.jn-bar-progress__fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width var(--dur-base) var(--ease);
}

/* ---------------------------------------------------------------------------
   Responsive Layout (Mobile ≤899px)
   --------------------------------------------------------------------------- */
@media (max-width: 899px), (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  .jn-header {
    height: 52px;
    padding: 0 var(--page-x, 16px);
  }

  .jn-header .btn {
    min-height: 44px;
    min-width: 44px;
  }

  .jn-body {
    padding: var(--space-4) var(--page-x, 16px) calc(var(--tabbar-total, 56px) + 24px);
    gap: var(--space-6);
  }

  .jn-hero {
    flex-direction: column;
    text-align: center;
    padding: var(--space-6) var(--space-4);
    gap: var(--space-4);
  }

  .jn-ring {
    width: 168px;
    height: 168px;
    margin: 0 auto;
  }

  .jn-hero__actions {
    flex-direction: column;
    width: 100%;
    gap: var(--space-2);
  }

  .jn-hero__actions .btn {
    width: 100%;
    min-height: 44px;
  }

  .jn-miles {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    padding: var(--space-3) 0;
  }

  .jn-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }

  .jn-stat {
    padding: var(--space-3) var(--space-4);
  }

  .jn-stat--chart {
    grid-column: span 2;
  }

  .jn-next {
    overflow-x: hidden;
  }

  .jn-next .strip {
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-2);
  }

  .jn-next .strip .card {
    scroll-snap-align: start;
    flex: none;
    width: 140px;
  }

  .jw-wall {
    padding: var(--space-4) var(--space-3);
    gap: var(--space-5);
  }

  .jw-row__head {
    position: sticky;
    top: var(--dock-h, 0px);
    z-index: 5;
    background: color-mix(in srgb, var(--surface-1) 94%, var(--bg));
    backdrop-filter: var(--blur-backdrop);
    -webkit-backdrop-filter: var(--blur-backdrop);
    padding: 8px 0;
    margin-bottom: 4px;
  }

  .jw-cells {
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
  }

  .jw-cell {
    min-width: 44px;
    min-height: 66px;
  }

  .jw-cell.is-unseen {
    opacity: 0.38;
  }

  .jw-cell.is-unseen .jw-cell__img {
    display: block;
    filter: grayscale(0.6) brightness(0.7);
  }

  .jw-cell.is-seen {
    opacity: 1;
  }
}
