* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #1a1a1a;
  color: #eee;
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 640px;
  padding: 1.5rem;
  position: relative;
}

#app-footer {
  margin-top: 2rem;
  text-align: center;
  display: flex;
  justify-content: center;
  gap: 1.25rem;
}

#reset-stats-btn,
#how-it-works-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0.6rem 1rem;
  border: none;
  background: none;
  color: #888;
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
}

#reset-stats-btn:hover,
#how-it-works-btn:hover {
  color: #aaa;
}

.hidden {
  display: none !important;
}

#loading,
#empty {
  text-align: center;
  font-size: 1.2rem;
  color: #aaa;
}

.image-wrap {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 1.5rem;
}

#painting-image {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  border-radius: 6px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  cursor: zoom-in;
}

#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  z-index: 100;
}

#lightbox-image {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
}

#metadata {
  text-align: center;
  margin-bottom: 1.5rem;
}

#title {
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
}

#artist {
  margin: 0.15rem 0;
  color: #ccc;
  font-size: 1.1rem;
}

#movements,
#country-year {
  margin: 0.15rem 0;
  color: #999;
  font-size: 0.95rem;
}

/* Wraps just the movement link(s), independent of the hidden/revealed
   toggle, so #movements' text-align: center centers only the visible text —
   the toggle is positioned absolute relative to this wrapper and never
   contributes to its width/centering. */
.movement-text {
  position: relative;
  display: inline-block;
}

.learn-more-link {
  color: inherit;
  text-decoration: none;
}

.learn-more-link:hover {
  color: #6ea8e0;
  text-decoration: underline;
}

#controls {
  display: flex;
  justify-content: center;
}

#reveal-btn {
  font-size: 1.1rem;
  padding: 0.75rem 2.5rem;
  border-radius: 8px;
  border: none;
  background: #3a6ea5;
  color: white;
  cursor: pointer;
}

#reveal-btn:hover {
  background: #4a7eb5;
}

#grade-buttons {
  display: flex;
  gap: 0.6rem;
  width: 100%;
}

.grade {
  flex: 1;
  font-size: 1rem;
  padding: 0.75rem 0;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  color: white;
}

.grade.again {
  background: #b33a3a;
}

.grade.hard {
  background: #b3843a;
}

.grade.good {
  background: #3aa15a;
}

.grade.easy {
  background: #3a8fb3;
}

.grade:hover {
  filter: brightness(1.15);
}

/* --- Art Movements Timeline --- */

.timeline-full-toggle {
  background: none;
  border: none;
  color: #6ea8e0;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  text-decoration: underline;
}

.timeline-full-toggle:hover {
  color: #8fbdec;
}

/* --- Year trigger (country/year line) ---
   The year itself is the click target that opens/closes #timeline-strip.
   Always visible (caret + color change), no hover-gating media queries,
   and explicitly never blue — this should read as an in-page control, not
   an external link (unlike .learn-more-link / .timeline-full-toggle). */
.year-trigger {
  display: inline-flex;
  align-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0.6rem 0.35rem;
  background: none;
  border: none;
  font: inherit;
  color: #999;
  cursor: pointer;
}

.year-trigger:hover {
  color: #ccc;
}

.year-caret {
  margin-left: 0.15em;
}

#timeline-strip {
  margin: 0.75rem 0;
  padding: 0.75rem;
  background: #242424;
  border-radius: 8px;
  text-align: left;
}

/* Shared-axis row component — used for both the 3-segment local view and
   the full-timeline expand. Each row is label | proportional bar-track |
   year range, matching the layout the full expand already used. */
:root {
  --timeline-name-width: 130px;
  --timeline-range-width: 78px;
  --timeline-gap: 0.5rem;
}

.timeline-local-strip {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.timeline-local-strip.has-century-grid {
  padding-top: 14px;
}

.timeline-row {
  display: flex;
  align-items: center;
  gap: var(--timeline-gap);
  font-size: 0.8rem;
  color: #bbb;
}

.timeline-row-this {
  color: #fff;
  font-weight: 600;
}

.timeline-row-name {
  flex: 0 0 var(--timeline-name-width);
  width: var(--timeline-name-width);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-row-track {
  position: relative;
  flex: 1;
  height: 6px;
}

/* Century gridlines — a single overlay spanning the full row list, aligned
   to the track column via the same fixed name/range widths every row uses
   (see .timeline-row-name / .timeline-row-range), so lines land in the
   same x-position on every row instead of drifting with label length. */
.timeline-grid-overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--timeline-name-width) + var(--timeline-gap));
  right: calc(var(--timeline-range-width) + var(--timeline-gap));
  pointer-events: none;
}

.timeline-grid-line {
  position: absolute;
  top: 14px;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.09);
}

.timeline-grid-line-label {
  position: absolute;
  top: -14px;
  left: 3px;
  font-size: 0.65rem;
  color: #666;
  white-space: nowrap;
}

.timeline-bar {
  position: absolute;
  top: 0;
  height: 6px;
  min-width: 4px;
  border-radius: 3px;
  background: #444;
}

.timeline-row-bar-this {
  background: #3a6ea5;
  /* Hard constraint: the anchor/matched bar always renders at full
     precedence over any overlapping neighbor. */
  opacity: 1 !important;
  z-index: 2;
}

/* Overlap treatment: reduced opacity on the non-anchor overlapping bar.
   Chosen over a vertical-offset approach because it reads clearly at the
   6px bar height used here without needing extra row height, and it keeps
   the anchor's full-opacity precedence trivially enforceable via z-index +
   opacity rather than juggling two vertical lanes. */
.timeline-row-bar-dimmed {
  opacity: 0.7;
  z-index: 1;
}

.timeline-marker {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px #242424;
}

.timeline-marker.marker-imprecise {
  opacity: 0.6;
}

.timeline-row-range {
  flex: 0 0 var(--timeline-range-width);
  width: var(--timeline-range-width);
  text-align: right;
  font-size: 0.75rem;
  color: #888;
}

.timeline-also-tagged {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #999;
  font-style: italic;
}

.timeline-full-toggle {
  display: block;
  margin-top: 0.6rem;
}

.timeline-full-list {
  position: relative;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid #333;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.timeline-full-list.has-century-grid {
  padding-top: calc(0.6rem + 14px);
}

.timeline-full-list.has-century-grid .timeline-grid-overlay {
  top: 0.6rem;
}

/* --- Intro / "How it works" modal --- */

#intro-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
}

#intro-modal .modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 12, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.modal-panel {
  background: linear-gradient(180deg, #232323 0%, #1c1c1c 100%);
  border: 1px solid #363636;
  border-radius: 16px;
  padding: 1.75rem 1.5rem 1.5rem;
  width: 100%;
  max-width: 420px;
  position: relative;
  text-align: left;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.55),
    0 2px 0 rgba(255, 255, 255, 0.04) inset;
}

.modal-icon {
  width: 44px;
  height: 44px;
  margin: 0 0 0.75rem;
  border-radius: 50%;
  background: rgba(58, 110, 165, 0.18);
  border: 1px solid rgba(110, 168, 224, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.modal-panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

.modal-body {
  color: #bbb;
  font-size: 0.95rem;
  line-height: 1.55;
  margin: 0 0 0.6rem;
  padding-left: 1.2rem;
}

.modal-body li + li {
  margin-top: 0.4rem;
}

.modal-body strong {
  color: #eee;
}

.modal-tip {
  color: #888;
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0 0 1.5rem;
}

.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: #999;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.modal-close:hover {
  color: #eee;
  background: rgba(255, 255, 255, 0.12);
}

#intro-cta {
  font-size: 1.05rem;
  padding: 0.75rem 2rem;
  border-radius: 8px;
  border: none;
  background: #3a6ea5;
  color: white;
  cursor: pointer;
  width: 100%;
}

#intro-cta:hover {
  background: #4a7eb5;
}
