/* dcim: a quiet, day-by-day photo page.
   theme.js sets data-theme on <html> (system setting until the visitor uses the toggle). */

:root {
  color-scheme: light;
  --bg: #F7F7F5;
  --text: #2C2E30;
  --text-2: #4A4D52;
  --muted: #6A6D72;
  --hairline: #E2E3E0;
  --placeholder: #DCDFDA;
  --land: #C9CBC6;
  --land-dots: #D2D4CF;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1C1D1F;
  --text: #E8E6E3;
  --text-2: #C9C6C2;
  --muted: #A09D99;
  --hairline: #313336;
  --placeholder: #35383C;
  --land: #45474B;
  --land-dots: #3A3C40;
}
@media (prefers-color-scheme: dark) { /* only matters if theme.js didn't run */
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #1C1D1F; --text: #E8E6E3; --text-2: #C9C6C2; --muted: #A09D99; --hairline: #313336; --placeholder: #35383C; --land: #45474B; --land-dots: #3A3C40;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 44px 20px 96px;
}
@media (min-width: 720px) { .page { padding: 48px 24px 96px; } }

/* Header */
.page-head { margin-bottom: 44px; }
.page-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.page-top h1 { margin: 0; font-size: 22px; font-weight: 500; line-height: 1.2; color: var(--text); }

/* "+" next to the theme button: opens the editor. Same icon-only treatment as the theme button below. */
#nav-bar .menu { display: flex; align-items: center; }
.add-link {
  position: relative;
  display: block;
  width: 32px;
  height: 32px;
  margin: -4px 0;
  color: var(--muted);
  font-size: 0;
  line-height: 0;
}
.add-link::before {
  content: "";
  position: absolute;
  inset: 6px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E") center / contain no-repeat;
}
.add-link:hover { color: var(--text); }
.add-link:focus-visible { outline: 2px solid var(--text-2); outline-offset: 2px; }

/* Light/dark button. theme.js creates it and sets its text; the text is hidden and an icon is drawn instead,
   so the shared script doesn't need to change. Moon in light mode, sun in dark mode. */
.theme-toggle {
  position: relative;
  width: 32px;
  height: 32px;
  margin: -4px -6px -4px 0; /* bigger tap target without moving the icon */
  padding: 0;
  border: 0;
  background: none;
  font-size: 0;
  line-height: 0;
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle::before {
  content: "";
  position: absolute;
  inset: 6px;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5z'/%3E%3C/svg%3E");
}
html[data-theme="dark"] .theme-toggle::before {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4'/%3E%3C/svg%3E");
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle:focus-visible, .tile:focus-visible { outline: 2px solid var(--text-2); outline-offset: 2px; }

/* Feed: "Ledger". Months newest first; each month's label is sticky inside its own
   section, so it stays put while that month is on screen and the next month pushes it away. No JS needed. */
.days { display: flex; flex-direction: column; gap: 96px; }
.month-sec { display: flex; gap: 24px; align-items: flex-start; }
.month {
  flex: 0 0 120px; position: sticky; top: 32px; padding-top: 14px; margin: 0;
  display: flex; flex-direction: column; font-size: 26px; font-weight: 400;
}
.month .mon { font-weight: 500; letter-spacing: 0.04em; line-height: 1; color: var(--text); }
.month .year { line-height: 1.1; color: var(--muted); }
.month-days { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 64px; }

.day { display: flex; gap: 24px; padding-top: 14px; border-top: 1px solid var(--hairline); }
/* the day number is sticky inside its own day: it lines up with the pinned month label (32 + 14) and the
   next day pushes it away. align-self stops it stretching to the day's height, which would undo sticky. */
.date { flex: 0 0 68px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 46px; align-self: flex-start; }
.date .dd { font-size: 30px; font-weight: 500; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.date .dow { font-size: 15px; color: var(--muted); }
.body { flex: 1; min-width: 0; max-width: 600px; display: flex; flex-direction: column; gap: 14px; }

/* a picked place opens the map: dotted underline, otherwise plain text */
.day-place-line { font-size: 19px; font-weight: 500; line-height: 1.3; color: var(--text-2); }
.day-place { font: inherit; color: var(--text-2); }
.day-sep { color: var(--muted); white-space: pre; }
button.day-place {
  padding: 0; border: 0; background: none; cursor: pointer; text-align: left;
  text-decoration: underline dotted; text-underline-offset: 4px; text-decoration-thickness: 1.5px;
}
button.day-place:hover { color: var(--text); }
button.day-place:focus-visible { outline: 2px solid var(--text-2); outline-offset: 2px; }
.day-title { margin: 0; font-size: 20px; font-weight: 400; line-height: 1.35; color: var(--text-2); }
.day-note { margin: 0; font-size: 18px; line-height: 1.55; color: var(--text-2); text-wrap: pretty; }

/* Phone: the month becomes a header row pinned to the top, and each day's number sits in a narrow column. */
@media (max-width: 719px) {
  .days { gap: 48px; }
  .month-sec { display: block; }
  .month {
    position: sticky; top: 0; z-index: 1; min-height: 48px; margin: 0 -20px; padding: 0 20px;
    flex-direction: row; align-items: center; gap: 8px; font-size: 18px;
    background: var(--bg); border-bottom: 1px solid var(--hairline);
  }
  .month .year { line-height: 1; }
  .month-days { padding-top: 18px; gap: 40px; }
  .day { gap: 12px; padding-top: 0; border-top: 0; }
  .date { flex: 0 0 44px; gap: 3px; top: 67px; } /* just under the 49px header, where it already sits (+18) */
  .date .dd { font-size: 22px; }
  .date .dow { font-size: 13px; }
  .body { gap: 12px; }
  .day-place-line { font-size: 17px; }
  .day-title { font-size: 18px; }
  .day-note { font-size: 17px; }
  .day-title { line-height: 1.3; }
  .day-note { line-height: 1.5; }
}

/* Justified rows. flex-grow = aspect ratio, so a row's photos share one height and fill the width. */
.rows { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; gap: 6px; }
@media (max-width: 719px) { .rows, .row { gap: 5px; } }
.tile {
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: var(--tile-radius, 0);
  overflow: hidden;
  background: var(--placeholder);
  cursor: zoom-in;
  display: block;
}
.tile.blank { cursor: default; }
.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.tile img.is-loaded { opacity: 1; }

.page-msg { margin: 0; color: var(--muted); }

/* Time scrubber: a thin bar down the right edge. Drag it (or tap anywhere on it) to move through the days. */
.scrub {
  position: fixed;
  top: 16px;
  bottom: 16px;
  right: 0;
  width: 20px;
  z-index: 20;
  touch-action: none;
  cursor: grab;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
}
.scrub[hidden] { display: none; }
.scrub::before { content: ""; position: absolute; inset: -8px 0 -8px -18px; } /* bigger grab area than it looks */
/* On touch screens the bar itself lets swipes through (so scrolling near the right edge isn't hijacked);
   only the thumb can be grabbed, with a finger-sized grab area around it. */
@media (max-width: 719px) { .scrub { top: 60px; } } /* below the pinned month header */
@media (pointer: coarse) {
  .scrub { pointer-events: none; touch-action: auto; }
  .scrub::before { display: none; }
  .scrub-thumb { pointer-events: auto; touch-action: none; }
  .scrub-thumb::after { content: ""; position: absolute; inset: -14px -10px -14px -30px; }
}
.scrub.dragging { cursor: grabbing; }
.scrub-ticks { position: absolute; inset: 0; pointer-events: none; }
.tick { position: absolute; right: 5px; width: 5px; height: 1px; background: var(--muted); opacity: 0.5; }
.tick.year { width: 11px; right: 4px; opacity: 0.9; }
.tick span {
  position: absolute;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  padding: 3px 5px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  color: var(--muted);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  opacity: 0;
  transition: opacity 0.15s;
}
.scrub.dragging .tick span, .scrub:focus-visible .tick span { opacity: 1; }
@media (hover: hover) { .scrub:hover .tick span { opacity: 1; } }

.scrub-thumb {
  position: absolute;
  top: 0;
  right: 4px;
  width: 4px;
  height: 36px;
  border-radius: 2px;
  background: var(--text-2);
  opacity: 0.4;
  transition: opacity 0.15s, width 0.15s, right 0.15s;
  will-change: transform;
}
.scrub.scrolling .scrub-thumb, .scrub.dragging .scrub-thumb, .scrub:focus-visible .scrub-thumb { opacity: 0.9; }
.scrub.dragging .scrub-thumb { width: 6px; right: 3px; }
@media (hover: hover) { .scrub:hover .scrub-thumb { opacity: 0.9; } }

.scrub-bubble {
  position: absolute;
  top: 0;
  right: 22px;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  max-width: 70vw;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--bg);
  background: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  will-change: transform;
}
.scrub.scrolling .scrub-bubble, .scrub.dragging .scrub-bubble, .scrub:focus-visible .scrub-bubble { opacity: 1; }
@media (hover: hover) { .scrub:hover .scrub-bubble { opacity: 1; } }
.scrub:focus-visible::after { content: ""; position: absolute; inset: -4px; border: 2px solid var(--text-2); border-radius: 6px; pointer-events: none; }

/* Photo viewer: deliberately plain. */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(14, 15, 16, 0.96);
  color: #E8E6E3;
  touch-action: pan-y;
}
.viewer.is-open { display: flex; }
.viewer figure { margin: 0; display: flex; flex-direction: column; align-items: center; max-width: 100vw; }
.viewer img {
  display: block;
  max-width: 100vw;
  max-height: calc(100vh - 4.5rem);
  max-height: calc(100dvh - 4.5rem);
  width: auto;
  height: auto;
}
.viewer figcaption {
  height: 4.5rem;
  display: flex;
  align-items: center;
  padding: 0 20px;
  font-size: 17px;
  color: #C9C6C2;
  text-align: center;
}
.viewer button {
  position: absolute;
  background: none;
  border: 0;
  color: #E8E6E3;
  font: inherit;
  cursor: pointer;
  opacity: 0.7;
  padding: 12px 16px;
  line-height: 1;
}
.viewer button:hover, .viewer button:focus-visible { opacity: 1; }
.viewer button:focus-visible { outline: 2px solid #E8E6E3; }
.viewer .v-close { top: 8px; right: 12px; font-size: 32px; }
.viewer .v-prev, .viewer .v-next { top: 50%; transform: translateY(-50%); font-size: 38px; }
.viewer .v-prev { left: 8px; }
.viewer .v-next { right: 8px; }
@media (max-width: 640px) { .viewer .v-prev, .viewer .v-next { display: none; } } /* swipe instead */

@media (prefers-reduced-motion: reduce) { .tile img { transition: none; } }

/* ---- Map. Opened from the header icon or a day's place name. ---- */

/* header icon: a folded map in a 44px tap target; filled while the map is open */
.map-link {
  position: relative; display: block; width: 44px; height: 44px; margin: -10px -6px;
  padding: 0; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 0;
}
.map-link[hidden] { display: none; }
.map-link::after {
  content: ""; position: absolute; left: 8px; top: 8px; width: 28px; height: 28px; /* the filled chip when open */
}
.map-link::before {
  content: ""; position: absolute; left: 12px; top: 12px; width: 20px; height: 20px; z-index: 1;
  background: currentColor;
  -webkit-mask: var(--map-icon) center / contain no-repeat;
  mask: var(--map-icon) center / contain no-repeat;
  --map-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M3.5 6.5 9 4l6 2.5L20.5 4v13.5L15 20l-6-2.5L3.5 20z'/%3E%3Cpath d='M9 4v13.5M15 6.5V20'/%3E%3C/svg%3E");
}
.map-link:hover { color: var(--text); }
.map-link.on { color: var(--bg); }
.map-link.on::after { background: var(--text); }
.map-link:focus-visible { outline: 2px solid var(--text-2); outline-offset: -4px; }
#nav-bar .menu { gap: 2px; }

/* the map sits above the photos, which follow what's selected on it */
body.map-open .feed-filter { display: none; } /* the line under the map says it instead */
.map-view { margin: -20px -20px 40px; } /* edge to edge on a phone */
.map-view[hidden] { display: none; }
@media (min-width: 640px) { .map-view { margin: -20px 0 40px; } }
.map-area { position: relative; width: 100%; overflow: hidden; }
.map-svg { display: block; }
.map-empty { margin: 0; padding: 48px 20px; color: var(--muted); font-size: 15px; text-align: center; }

.map-land { fill: none; stroke: var(--land); stroke-width: 1; stroke-linejoin: round; }
.map-dot { fill: var(--text); }
.map-home-ring { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.map-ring { fill: none; stroke: var(--text); stroke-width: 1.5; }
.map-label { font-size: 14px; font-weight: 400; fill: var(--muted); }
.map-label.on { fill: var(--text); font-weight: 500; }
.map-hit { fill: transparent; outline: none; pointer-events: none; } /* taps are matched to the nearest dot in JS */
.map-svg { cursor: default; }
.map-label { cursor: pointer; }
.map-hit:focus-visible { stroke: var(--text-2); stroke-width: 2; stroke-dasharray: 2 3; }
.glow-a { stop-color: var(--text); stop-opacity: 0.16; }
.glow-b { stop-color: var(--text); stop-opacity: 0.06; }
.glow-c { stop-color: var(--text); stop-opacity: 0; }
html[data-theme="dark"] .glow-a { stop-opacity: 0.20; }
html[data-theme="dark"] .glow-b { stop-opacity: 0.07; }

/* one selection line under the map, with a hairline above */
.map-sel {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 62px; margin: 0 20px; padding: 12px 0;
  border-top: 1px solid var(--hairline);
}
@media (min-width: 640px) { .map-sel { margin: 0; } }
.map-sel-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.map-sel-text strong { font-size: 19px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-sel-text span { font-size: 16px; color: var(--muted); }
.map-go {
  flex-shrink: 0; font: inherit; font-size: 14px; color: var(--text); background: none; border: 0;
  padding: 10px 0 10px 10px; cursor: pointer;
}
.map-go:hover { text-decoration: underline; }
.map-go:focus-visible { outline: 2px solid var(--text-2); outline-offset: 2px; }

/* edit mode only: set home */
.map-home-edit { display: flex; align-items: center; gap: 10px; margin: 4px 20px 0; }
.map-home-edit:empty { display: none; }
@media (min-width: 640px) { .map-home-edit { margin: 4px 0 0; } }
.map-home-label { font-size: 14px; color: var(--muted); }
.map-home-edit .ed-place { flex: 1; }
.map-home-edit .ed-place input {
  font: inherit; font-size: 14px; color: var(--text-2); background: transparent;
  border: 1px dashed var(--hairline); padding: 6px 8px;
}

/* the filtered feed: one quiet line on top */
.feed-filter { display: flex; align-items: baseline; flex-wrap: wrap; font-size: 17px; color: var(--muted); margin-bottom: -28px; }
.feed-all {
  font: inherit; color: var(--text); background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.feed-all:focus-visible { outline: 2px solid var(--text-2); outline-offset: 2px; }

/* the way back out of a zoomed map: "All › Japan › Kansai" in the top-left corner */
.map-trail {
  position: absolute; top: 10px; left: 14px; z-index: 2;
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  max-width: calc(100% - 28px); padding: 2px 6px;
  font-size: 13px; color: var(--muted); background: color-mix(in srgb, var(--bg) 85%, transparent);
}
.map-trail[hidden] { display: none; }
.map-trail button {
  font: inherit; color: var(--muted); background: none; border: 0; padding: 6px 0; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.map-trail button:hover { color: var(--text); }
.map-trail button:focus-visible { outline: 2px solid var(--text-2); outline-offset: 2px; }
.map-trail-here { color: var(--text); }
.map-trail-sep { opacity: 0.7; }

.map-sel-text.view strong { font-weight: 400; }
.map-sel-acts { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.map-zoom {
  font: inherit; font-size: 14px; color: var(--muted); background: none; border: 0; padding: 10px 0; cursor: pointer;
}
.map-zoom:hover { color: var(--text); text-decoration: underline; }
.map-zoom:focus-visible { outline: 2px solid var(--text-2); outline-offset: 2px; }

/* faint city names for context when zoomed in */
.map-city { font-size: 11px; fill: var(--muted); opacity: 0.8; }
.map-city-dot { fill: var(--muted); opacity: 0.6; }

/* the places in view, as one quiet wrapping line of names under the map */
.map-list { margin: -4px 20px 0; font-size: 16px; line-height: 1.9; color: var(--muted); }
.map-list:empty { display: none; }
@media (min-width: 640px) { .map-list { margin: -4px 0 0; } }
.map-list-item {
  font: inherit; color: var(--text-2); background: none; border: 0; padding: 0; cursor: pointer;
}
.map-list-item:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
/* with one place selected, the rest of the list steps back so the selected one stands out */
.map-list.has-sel .map-list-item { color: var(--muted); }
.map-list.has-sel .map-list-item:hover { color: var(--text-2); }
.map-list-item.on, .map-list.has-sel .map-list-item.on { color: var(--text); font-weight: 500; }
.map-list-item:focus-visible { outline: 2px solid var(--text-2); outline-offset: 2px; }
.map-list-n { color: var(--muted); font-size: 12px; font-weight: 400; }
.map-list-sep, .map-list-more { white-space: pre; }
