/* Daily Archive — one stylesheet, bundled into the Worker.
   Visual language: kin to Galarie v2 (parchment ground, forest ink, fern and
   terracotta accents, DM Serif Display over DM Sans). Quiet gallery: the
   photographs carry the page and nothing competes with them. */

/* ---------------------------------------------------------------- fonts -- */
/* Served from /a/f/*.woff2 by the Worker itself. No third-party requests. */
@font-face {
  font-family: 'DM Sans';
  src: url('/a/f/dm-sans-300.woff2') format('woff2');
  font-weight: 300; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: url('/a/f/dm-sans-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: url('/a/f/dm-sans-500.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'DM Serif Display';
  src: url('/a/f/dm-serif-display-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

/* --------------------------------------------------------------- tokens -- */
:root {
  --font-display: 'DM Serif Display', Georgia, 'Times New Roman', serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --ground: #f4f1ec;
  --ground-deep: #ede9e1;
  --surface: #fafaf6;
  --surface-2: #f0ede5;

  --ink: #2c3328;
  --ink-2: #5f6d57;
  --ink-3: #8d9a84;

  --accent: #5c7a52;
  --accent-deep: #4a5744;
  --accent-warm: #c2785c;

  --line: #d4cfc3;
  --line-soft: #e3dfd6;

  --shadow-lift: 0 18px 60px rgba(44, 51, 40, 0.10);
  --frame: 1100px;
  --wide: 1500px;
  --radius: 10px;
  --radius-s: 6px;

  /* The justified grid's row height. Tiles size themselves from this and their
     own aspect ratio, so density is a single number to tune per breakpoint. */
  --row-h: 190px;
  --topbar-h: 3rem;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #151713;
    --ground-deep: #0f110e;
    --surface: #1d201b;
    --surface-2: #252922;

    --ink: #e9e6dc;
    --ink-2: #a6b09d;
    --ink-3: #77816e;

    --accent: #9bb08f;
    --accent-deep: #b3c5a8;
    --accent-warm: #d89b7e;

    --line: #2f342c;
    --line-soft: #272b24;

    --shadow-lift: 0 18px 60px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

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

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button, input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

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

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  color: var(--ink);
  padding: 0.75rem 1.25rem;
  border-radius: 0 0 var(--radius-s) 0;
  z-index: 400;
}
.skip:focus { left: 0; }

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

.label {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.75px;
  color: var(--ink-3);
}

/* -------------------------------------------------------------- buttons -- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5625rem 1.25rem;
  border-radius: var(--radius-s);
  border: 0.5px solid transparent;
  background: var(--accent);
  color: #fafaf6;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.btn:hover { background: var(--accent-deep); }
.btn[disabled] { opacity: 0.5; cursor: default; }

@media (prefers-color-scheme: dark) {
  .btn { color: #151713; }
}

.btn-quiet {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--line);
}
.btn-quiet:hover {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--ink-3);
}

.btn-bare {
  background: none;
  border: none;
  padding: 0.25rem;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 0.8125rem;
}
.btn-bare:hover { color: var(--ink); }

.btn-danger { background: var(--accent-warm); }
.btn-danger:hover { background: var(--accent-warm); filter: brightness(0.92); }

/* --------------------------------------------------------------- header -- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 120;
  background: color-mix(in srgb, var(--ground) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 0.5px solid var(--line-soft);
}

.topbar-inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0.8125rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.wordmark {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}
.wordmark span { color: var(--accent-warm); }

.topbar nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.navlink {
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-s);
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--ink-2);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.navlink:hover { color: var(--ink); background: var(--surface); }
.navlink[aria-current='page'] { color: var(--accent); }

/* The nav has to fit a 320px phone without a sideways scroll, so the longest
   label has a short form. */
.on-narrow { display: none; }

@media (max-width: 560px) {
  .topbar-inner { padding: 0.75rem 0.75rem; gap: 0.25rem; }
  .wordmark { font-size: 1.125rem; }
  .navlink { padding: 0.4rem 0.5rem; }
  .on-wide { display: none; }
  .on-narrow { display: inline; }
}

/* --------------------------------------------------------------- layout -- */
main { max-width: var(--wide); margin: 0 auto; padding: 2.5rem 1.5rem 6rem; }
main.narrow { max-width: var(--frame); }

.page-head { margin-bottom: 2.5rem; }
.page-head h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.15;
  margin: 0.35rem 0 0;
  letter-spacing: -0.01em;
}
.page-head .sub {
  margin: 0.5rem 0 0;
  color: var(--ink-2);
  font-size: 0.9375rem;
}

/* Only draw the separator when the day actually carries a folder label. */
#day-label:not(:empty)::after {
  content: '·';
  font-style: normal;
  color: var(--ink-3);
  margin: 0 0.4rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

/* ------------------------------------------------------------- timeline -- */
.month {
  margin: 0 0 3.5rem;
}
.month-head {
  position: sticky;
  top: var(--topbar-h);
  z-index: 40;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.75rem 0 0.875rem;
  margin-bottom: 1.25rem;
  background: linear-gradient(var(--ground) 62%, transparent);
  border-bottom: 0.5px solid var(--line-soft);
}
.month-head h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.6rem;
  margin: 0;
  letter-spacing: -0.01em;
}
.month-head .count { color: var(--ink-3); font-size: 0.8125rem; }

.day { margin: 0 0 2.25rem; }

.day-head {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  margin: 0 0 0.625rem;
  flex-wrap: wrap;
}
.day-head a {
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 0.5px solid transparent;
}
.day-head a:hover { border-bottom-color: var(--ink-3); }
.day-head .day-label {
  font-size: 0.8125rem;
  font-style: italic;
  color: var(--accent-warm);
}
.day-head .count {
  font-size: 0.75rem;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

/* Justified grid. Each tile flex-grows in proportion to its aspect ratio, so
   a row fills the width and every photo keeps its true shape. */
.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.grid::after { content: ''; flex-grow: 999999999; }

.tile {
  position: relative;
  display: block;
  height: var(--row-h);
  flex-grow: 1;
  flex-basis: calc(var(--ar, 1.5) * var(--row-h));
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 3px;
  overflow: hidden;
  background: var(--surface-2);
  cursor: zoom-in;
  contain: layout paint;
}
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
  opacity: 0;
}
.tile img.ready { opacity: 1; }
.tile:hover img { transform: scale(1.02); }

/* Two landscape photographs to a row on a phone, four portraits. Tuned so the
   row never collapses to a single tile, which reads as a list, not a gallery. */
@media (max-width: 720px) {
  :root { --row-h: 112px; }
  .grid { gap: 4px; }
  main { padding: 1.25rem 0.5rem 5rem; }
}

@media (max-width: 380px) {
  :root { --row-h: 94px; }
  .topbar-inner { padding: 0.7rem 0.5rem; }
  .wordmark { font-size: 1.0625rem; }
  .navlink { font-size: 0.75rem; padding: 0.35rem 0.4rem; }
}

.day-skeleton {
  height: var(--row-h);
  border-radius: 3px;
  background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface) 50%, var(--surface-2) 70%);
  background-size: 300% 100%;
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

.sentinel { height: 1px; }

.end-note, .empty {
  text-align: center;
  color: var(--ink-3);
  font-size: 0.875rem;
  padding: 3rem 1rem;
}
.empty h2 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--ink);
  font-size: 1.5rem;
  margin: 0 0 0.5rem;
}

/* ----------------------------------------------------------- month jump -- */
.jump {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  background: color-mix(in srgb, var(--ground-deep) 82%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.jump[data-open='true'] { display: block; }

.jump-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(360px, 88vw);
  background: var(--surface);
  border-left: 0.5px solid var(--line);
  box-shadow: var(--shadow-lift);
  overflow-y: auto;
  padding: 1.5rem;
  animation: slide-in 0.35s var(--ease);
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }

.jump-panel h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.25rem;
  margin: 0 0 1.25rem;
}

.jump-year { margin-bottom: 1.5rem; }
.jump-year > h3 {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.75px;
  color: var(--ink-3);
  margin: 0 0 0.625rem;
}
.jump-months { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.jump-months button {
  padding: 0.3rem 0.7rem;
  border-radius: 100px;
  border: 0.5px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  font-size: 0.75rem;
  cursor: pointer;
}
.jump-months button:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--surface);
}

/* ------------------------------------------------------------- lightbox -- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  background: rgba(12, 13, 11, 0.96);
  color: #f2efe7;
  touch-action: pan-y;
}
.lightbox[data-open='true'] { display: block; }
body.locked { overflow: hidden; }

.lb-stage {
  position: absolute;
  inset: 3.5rem 0 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1rem;
}
.lb-stage img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 2px;
  animation: lb-in 0.3s var(--ease);
}
@keyframes lb-in { from { opacity: 0; transform: scale(0.985); } }

.lb-bar {
  position: absolute;
  left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
}
.lb-bar.top { top: 0; }
.lb-bar.bottom { bottom: 0; justify-content: center; }

.lb-bar .name {
  font-size: 0.8125rem;
  color: rgba(242, 239, 231, 0.72);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-bar .spacer { margin-left: auto; }

.lb-btn {
  background: rgba(242, 239, 231, 0.08);
  border: 0.5px solid rgba(242, 239, 231, 0.16);
  color: #f2efe7;
  border-radius: var(--radius-s);
  padding: 0.4rem 0.85rem;
  font-size: 0.8125rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.lb-btn:hover { background: rgba(242, 239, 231, 0.16); }

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 100px;
  font-size: 1.25rem;
  line-height: 1;
}
.lb-nav.prev { left: 0.75rem; }
.lb-nav.next { right: 0.75rem; }

.lb-counter {
  font-size: 0.75rem;
  letter-spacing: 1.5px;
  color: rgba(242, 239, 231, 0.6);
}

@media (max-width: 720px) {
  .lb-nav { display: none; }
  .lb-stage { inset: 3.25rem 0 3.75rem; padding: 0; }
}

/* ---------------------------------------------------------------- login -- */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 2rem 1.5rem;
}
.login {
  width: min(380px, 100%);
  text-align: center;
}
.login .mark {
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1.1;
  margin: 0 0 0.5rem;
}
.login .mark span { color: var(--accent-warm); }
.login p.sub {
  color: var(--ink-2);
  font-size: 0.9375rem;
  margin: 0 0 2.25rem;
}
.login form { display: flex; flex-direction: column; gap: 0.75rem; }
.login input {
  width: 100%;
  padding: 0.8125rem 1rem;
  border-radius: var(--radius-s);
  border: 0.5px solid var(--line);
  background: var(--surface);
  font-weight: 300;
  text-align: center;
  letter-spacing: 0.08em;
}
.login input::placeholder { color: var(--ink-3); letter-spacing: 0.02em; }
.login .btn { justify-content: center; padding: 0.8125rem 1rem; }
.login .note {
  margin-top: 2.5rem;
  font-size: 0.75rem;
  color: var(--ink-3);
}

.flash {
  margin: 0 0 0.25rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-s);
  font-size: 0.8125rem;
  background: color-mix(in srgb, var(--accent-warm) 12%, transparent);
  border: 0.5px solid color-mix(in srgb, var(--accent-warm) 30%, transparent);
  color: var(--ink);
}

/* ---------------------------------------------------------------- admin -- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.875rem;
  margin-bottom: 2.5rem;
}
.stat {
  background: var(--surface);
  border: 0.5px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 1.125rem 1.25rem;
}
.stat .k {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.75px;
  color: var(--ink-3);
}
.stat .v {
  font-family: var(--font-display);
  font-size: 1.75rem;
  line-height: 1.2;
  margin-top: 0.375rem;
}
.stat .v small { font-family: var(--font-body); font-size: 0.875rem; color: var(--ink-2); }
.stat .note { font-size: 0.75rem; color: var(--ink-3); margin-top: 0.25rem; }
.stat.warn { border-color: color-mix(in srgb, var(--accent-warm) 45%, transparent); }
.stat.warn .v, .stat.warn .note { color: var(--accent-warm); }

.meter {
  margin-top: 0.75rem;
  height: 5px;
  border-radius: 100px;
  background: var(--surface-2);
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 100px;
}
.meter i.warn { background: var(--accent-warm); }

.panel {
  background: var(--surface);
  border: 0.5px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.panel h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.25rem;
  margin: 0 0 0.75rem;
}
.panel pre {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.admin-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-tile {
  position: relative;
  width: 132px;
  height: 132px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--surface-2);
}
.admin-tile img { width: 100%; height: 100%; object-fit: cover; }
.admin-tile button {
  position: absolute;
  right: 5px;
  bottom: 5px;
  border: none;
  border-radius: 100px;
  padding: 0.2rem 0.6rem;
  font-size: 0.6875rem;
  font-weight: 500;
  background: rgba(18, 19, 17, 0.72);
  color: #f2efe7;
  cursor: pointer;
}
.admin-tile button:hover { background: var(--accent-warm); }
.admin-tile.gone { opacity: 0.25; pointer-events: none; }

select.daypick {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-s);
  border: 0.5px solid var(--line);
  background: var(--surface);
  max-width: 100%;
}

/* ---------------------------------------------------------------- toast -- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.75rem;
  transform: translate(-50%, 1rem);
  z-index: 500;
  background: var(--ink);
  color: var(--ground);
  padding: 0.625rem 1.125rem;
  border-radius: 100px;
  font-size: 0.8125rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.toast[data-show='true'] { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------------- footer -- */
.foot {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  border-top: 0.5px solid var(--line-soft);
  color: var(--ink-3);
  font-size: 0.75rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
