/* Shared shell (tokens, body background, theme toggle, dark base) lives in
   ../theme.css. This file only holds the weeks-view layout. */

:root {
  --week-size: 12px;
  --week-gap: 3px;
  /* Life-phase colors, borrowed from year-in-pixels' palette. Drawn as a
     thin line along the bottom of each week; overlapping phases split that
     line into equal segments (composed in app.js). */
  --phase-high-school: #839ed7;
  --phase-undergrad: #df91a9;
  --phase-bo: #ffa409;
  --phase-mam: #c8c5c6;
  --phase-phd: #7fa875;
  --phase-line: 3px;
}

body {
  width: min(100%, 820px);
}

.site-header,
main,
footer {
  width: min(700px, calc(100% - 32px));
  margin-right: auto;
  margin-left: auto;
}

main {
  padding: 0;
}

.site-header {
  position: relative;
  margin-bottom: 28px;
}

.site-header nav {
  margin-bottom: 20px;
}

.site-header > p {
  max-width: 620px;
  margin: 0;
  color: var(--ink);
}

.site-header > .timeline-meta {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.timeline-meta a {
  text-underline-offset: 2px;
}

.site-header .preview-note {
  margin-top: 10px;
  color: #9a5e39;
  font-size: 12px;
}

.preview-note code {
  padding: 1px 4px;
  background: #f5f2ed;
  border-radius: 3px;
}

.view-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  justify-content: flex-end;
  margin-bottom: 18px;
}

.view-switch button {
  padding: 1px 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 12px;
  text-decoration: underline;
  text-decoration-color: #c0c0ba;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  cursor: pointer;
}

.view-switch button:hover,
.view-switch button:focus-visible {
  color: var(--ink);
  text-decoration-color: var(--ink);
  outline: none;
}

.view-switch button.active {
  color: var(--ink);
  font-weight: 500;
  text-decoration-color: var(--ink);
  text-decoration-thickness: 2px;
}

.duration-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 14px;
  margin: -8px 0 14px;
  color: var(--muted);
  font-size: 12px;
}

.duration-legend[hidden] { display: none; }
.duration-key { display: inline-flex; align-items: center; gap: 5px; }
.duration-swatch {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: transparent;
}
.duration-swatch.duration-high-school { background: var(--phase-high-school); }
.duration-swatch.duration-undergrad { background: var(--phase-undergrad); }
.duration-swatch.duration-bo { background: var(--phase-bo); }
.duration-swatch.duration-mam { background: var(--phase-mam); }
.duration-swatch.duration-phd { background: var(--phase-phd); }

.timeline[hidden],
.memory-list-view[hidden],
.memory-image-view[hidden] {
  display: none;
}

.memory-list-view {
  padding: 12px 16px;
  border: 1px solid rgba(92, 100, 102, 0.2);
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 7px 20px rgba(44, 52, 58, 0.11), 0 1px 3px rgba(44, 52, 58, 0.08);
}

.list-memory {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 16px;
  width: 100%;
  padding: 9px 4px;
  border: 0;
  border-bottom: 1px solid #e2e2dd;
  color: var(--ink);
  background: transparent;
  font: inherit;
  text-align: left;
}

.list-memory:hover {
  background: rgba(255, 255, 255, 0.65);
}

.list-memory-date {
  color: var(--muted);
  font-size: 12px;
}

.list-memory-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px;
  font-size: 16px;
}

.list-memory-trigger {
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.list-memory-trigger:hover,
.list-memory-trigger:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
  outline: none;
}

.list-memory-link {
  font-size: 12px;
  white-space: nowrap;
  text-underline-offset: 3px;
}

.memory-image-view {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 16px;
  border: 1px solid rgba(92, 100, 102, 0.2);
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 7px 20px rgba(44, 52, 58, 0.11), 0 1px 3px rgba(44, 52, 58, 0.08);
}

.image-memory {
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #d3d3ce;
  border-radius: 2px;
  background: #fff;
  cursor: pointer;
}

.image-memory img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 150ms ease;
}

.image-memory:hover,
.image-memory:focus-visible {
  border-color: #555;
  outline: 1px solid #555;
  outline-offset: 1px;
}

.image-memory:hover img,
.image-memory:focus-visible img {
  opacity: 0.88;
}

.decade {
  margin: 0 0 16px;
  padding: 18px 20px;
  border: 1px solid rgba(92, 100, 102, 0.2);
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 7px 20px rgba(44, 52, 58, 0.11), 0 1px 3px rgba(44, 52, 58, 0.08);
}

.decade-heading {
  margin: 0 0 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid #d7d7d1;
  font-size: 16px;
  line-height: 1.3;
}

.year-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: start;
  min-height: 26px;
  margin: 4px 0;
}

.year-label {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-variant-numeric: tabular-nums;
}

.year-label strong {
  min-width: 21px;
  font-size: 12px;
}

.year-label span {
  color: var(--muted);
  font-size: 12px;
}

.week-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--week-gap);
  width: 100%;
  min-height: 22px;
}

.compact-years {
  align-content: flex-start;
  padding: 2px 0;
}

.year-marker {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.week {
  flex: 0 0 var(--week-size);
  width: var(--week-size);
  height: var(--week-size);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 1px solid #d3d3d3;
  border-radius: 1px;
  background: transparent;
}

.week.lived {
  border-color: #bdbdbd;
  background: transparent;
}

.week.age-marker {
  display: grid;
  place-items: center;
  border-color: #999;
  color: var(--ink);
  background: transparent;
  font-size: 6px;
  font-weight: 600;
  line-height: 1;
}

.week.current {
  position: relative;
  z-index: 2;
  flex: 0 1 auto;
  width: auto;
  height: auto;
  min-height: 24px;
  padding: 2px 7px;
  border: 1px solid #555;
  border-radius: 2px;
  color: #222;
  background: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: 0 0 0 rgba(207, 154, 55, 0);
  animation: live-glow 2.8s ease-in-out infinite;
}

.live-spark {
  display: inline-block;
  color: #bd7d18;
  animation: twinkle 1.4s ease-in-out infinite;
}

.live-marker { white-space: nowrap; }

.beyond-now {
  margin: 10px 0 28px;
  padding: 7px 9px;
  border: 1px solid #aaa;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 16px;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.35; transform: scale(0.8) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.2) rotate(18deg); }
}

@keyframes live-glow {
  0%, 100% { box-shadow: 0 0 0 rgba(207, 154, 55, 0); }
  50% { box-shadow: 0 0 9px rgba(207, 154, 55, 0.35); }
}

.week.has-memory {
  flex: 0 1 auto;
  width: auto;
  height: auto;
  min-height: 21px;
  padding: 1px 6px;
  border: 1px solid #999;
  border-radius: 2px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  font: inherit;
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.week.has-memory:hover,
.week.has-memory:focus-visible {
  border-color: #222;
  outline: 1px solid #222;
  outline-offset: 1px;
}

/* Life phases show as a crayon line along the bottom of the week. Overlapping
   phases stack their lines upward (one per phase). --week-line (the colors)
   and --week-line-pos (their stacked positions) are composed per week in
   app.js. The line is drawn on ::after so the crayon filter only roughens the
   stroke, leaving the box and its text crisp. */
.crayon-defs { position: absolute; width: 0; height: 0; }

.week.in-duration {
  position: relative;
  isolation: isolate;
}

.week.in-duration::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: var(--week-line);
  background-repeat: no-repeat;
  background-position: var(--week-line-pos, bottom);
  background-size: 100% var(--phase-line);
  filter: url(#crayon);
}

.tooltip {
  position: fixed;
  z-index: 20;
  width: min(280px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  padding: 9px 10px;
  border: 1px solid #c8c8c2;
  border-radius: 2px;
  background: #fffefa;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.tooltip.pinned {
  border-color: #888880;
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.14);
}

.tooltip > div + div {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid #eee;
}

.tooltip p { margin: 0; }
.tooltip-image {
  display: block;
  width: 100%;
  max-height: 220px;
  margin-bottom: 7px;
  border-radius: 2px;
  object-fit: contain;
}
.tooltip-date { color: var(--muted); font-size: 12px; }
.tooltip-title { margin-top: 2px !important; font-size: 12px; font-weight: 600; }
.tooltip-title span { margin-right: 5px; }
.tooltip-note { margin-top: 2px !important; color: var(--ink); font-size: 12px; }
.tooltip-link {
  display: inline-block;
  margin-top: 7px;
  font-size: 12px;
  text-underline-offset: 2px;
}

footer {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid #d7d7d1;
  color: var(--muted);
  font-size: 12px;
}

footer p { margin: 0; }

html[data-theme="dark"] .decade,
html[data-theme="dark"] .memory-list-view,
html[data-theme="dark"] .memory-image-view {
  border-color: #514d48;
  background: #302e2b;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32), 0 1px 4px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .decade-heading,
html[data-theme="dark"] footer { border-color: #55504a; }
html[data-theme="dark"] .week { border-color: #5b5751; }
html[data-theme="dark"] .week.lived { border-color: #6b665f; }
html[data-theme="dark"] .week.has-memory,
html[data-theme="dark"] .week.current {
  border-color: #8b857c;
  color: #e8e3dc;
  background: rgba(62, 59, 55, 0.94);
}
html[data-theme="dark"] .list-memory { border-color: #4e4a45; color: var(--ink); }
html[data-theme="dark"] .list-memory:hover { background: rgba(76, 72, 67, 0.65); }
html[data-theme="dark"] .image-memory { border-color: #5b5751; background: #302e2b; }
html[data-theme="dark"] .tooltip {
  border-color: #6d675f;
  color: var(--ink);
  background: #302e2b;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.34);
}
html[data-theme="dark"] .tooltip > div + div { border-color: #514d48; }
html[data-theme="dark"] .beyond-now { border-color: #68625b; background: rgba(62, 59, 55, 0.94); }

@media (max-width: 680px) {
  body {
    width: 100%;
    padding-top: 18px;
  }

  .site-header,
  main,
  footer {
    width: calc(100% - 24px);
  }

  main {
    padding: 0;
  }

  .decade {
    padding: 14px;
  }

  .memory-list-view,
  .memory-image-view {
    padding: 12px;
  }

  .years {
    overflow: visible;
  }

  .year-row {
    grid-template-columns: 76px 1fr;
  }

  .list-memory {
    grid-template-columns: 105px 1fr;
    gap: 10px;
  }

  .memory-image-view {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .week.current,
  .live-spark { animation: none; }
}
