/* ------------------------------------------------------------------
   Daily Drawings: a dotted-notebook page.
   The one memorable thing is the year grid: a dot for every day,
   filled in on the days a drawing was made. Everything else is quiet.
------------------------------------------------------------------- */

@font-face {
  font-family: 'Jost';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/jost-latin-wght-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('/fonts/newsreader-latin-wght-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url('/fonts/newsreader-latin-wght-italic.woff2') format('woff2');
}

:root {
  color-scheme: light dark;
  --paper: #f5f6f9;
  --paper-2: #ffffff;
  --ink: #151a33;
  --ink-2: #4a5170;
  --ink-3: #737a97;
  --dot: #c8cddb;
  --line: #dadde8;
  --accent: #2a45e6;
  --accent-ink: #ffffff;
  --danger: #b3261e;
  --sans: 'Jost', 'Avenir Next', 'Century Gothic', 'Segoe UI', system-ui, sans-serif;
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #11141f;
    --paper-2: #181c2b;
    --ink: #eceef6;
    --ink-2: #b4b9d0;
    --ink-3: #8a90ad;
    --dot: #2b3146;
    --line: #272d42;
    --accent: #8fa2ff;
    --accent-ink: #0f1330;
    --danger: #ff8a80;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  background-color: var(--paper);
  /* the notebook: a quiet dot grid behind everything */
  background-image: radial-gradient(circle at center, var(--dot) 1.1px, transparent 1.7px);
  background-size: 22px 22px;
}
a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 40px);
}

/* ---------- Masthead ---------- */
.masthead { padding-block: clamp(40px, 8vw, 88px) clamp(20px, 3vw, 32px); }
.masthead h1 {
  margin: 0 0 18px;
  font: 600 clamp(3rem, 10.5vw, 7.2rem) / 0.88 var(--sans);
  letter-spacing: -0.045em;
}
.lede {
  margin: 0;
  max-width: 34rem;
  min-height: 1.5em;
  font: italic 400 clamp(1.1rem, 2.4vw, 1.3rem) / 1.45 var(--serif);
  color: var(--ink-2);
}

/* ---------- Year grid ---------- */
.year { padding-bottom: clamp(24px, 4vw, 44px); }
.year-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 20px;
  margin-bottom: 12px;
}
.years { display: flex; gap: 18px; }
.years button {
  margin: 0;
  padding: 2px 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  font: 500 1rem var(--sans);
  color: var(--ink-3);
  cursor: pointer;
}
.years button:hover { color: var(--ink); }
.years button[aria-pressed='true'] { color: var(--ink); border-bottom-color: var(--accent); }
.year-note { margin: 0; font: italic 400 1rem var(--serif); color: var(--ink-3); }

.gridscroll { overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; scrollbar-color: var(--dot) transparent; }
.monthrow { display: grid; height: 1.1rem; margin-bottom: 4px; font: 500 0.72rem / 1 var(--sans); color: var(--ink-3); }
.monthrow span { white-space: nowrap; }

.daygrid { display: grid; grid-template-rows: repeat(7, auto); grid-auto-flow: column; }
.cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
}
.cell::before {
  content: '';
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: var(--dot);
}
.cell.pad::before { display: none; }
.cell.future::before { background: none; box-shadow: inset 0 0 0 1px var(--dot); }
.cell.has { cursor: pointer; }
.cell.has::before {
  width: 66%;
  height: 66%;
  background: var(--accent);
  transition: transform 0.12s ease;
  animation: fill 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.25) backwards;
  animation-delay: var(--d, 0ms);
}
.cell.has:hover::before,
.cell.has:focus-visible::before { transform: scale(1.3); }
.cell.has:focus-visible { outline-offset: 0; border-radius: 50%; }
@keyframes fill { from { transform: scale(0); } }

.tip {
  position: fixed;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px 7px 7px;
  background: var(--ink);
  color: var(--paper);
  font: 500 0.85rem / 1.3 var(--sans);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
}
.tip.show { opacity: 1; }
.tip img { display: block; width: 54px; height: 54px; object-fit: cover; background: #fff; }
.tip em { display: block; font: italic 400 0.85rem var(--serif); opacity: 0.75; }

/* ---------- Gallery ---------- */
.month {
  display: grid;
  grid-template-columns: 10.5rem minmax(0, 1fr);
  gap: 0 clamp(20px, 3vw, 40px);
  padding: clamp(20px, 3vw, 36px) 0 6px;
}
.month-label { position: sticky; top: 24px; align-self: start; padding-bottom: 12px; }
.month-label h2 { margin: 0; font: 600 clamp(1.7rem, 3vw, 2.3rem) / 1 var(--sans); letter-spacing: -0.03em; }
.month-label p { margin: 8px 0 0; font: italic 400 1rem / 1.35 var(--serif); color: var(--ink-3); }
.month-label p span { display: block; }

.works { columns: 3 230px; column-gap: clamp(18px, 2.4vw, 30px); }
.work {
  display: block;
  width: 100%;
  margin: 0 0 30px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: zoom-in;
  break-inside: avoid;
}
.work img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  outline: 1px solid var(--line);
  outline-offset: 0;
  transition: outline-color 0.15s, outline-offset 0.15s;
}
.work:hover img,
.work:focus-visible img { outline: 2px solid var(--accent); outline-offset: 4px; }
.work:focus-visible { outline: none; }
.work .cap { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 10px; }
.work .t { font: 500 1rem / 1.25 var(--sans); }
.work time { margin-left: auto; font: italic 400 0.95rem var(--serif); color: var(--ink-3); white-space: nowrap; }
.work:hover .t { color: var(--accent); }

.empty { padding: 72px 0; font: italic 400 1.25rem var(--serif); color: var(--ink-3); }
.site-foot { padding-block: 56px 44px; font: 400 0.9rem var(--sans); color: var(--ink-3); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px 24px;
  background: rgba(14, 18, 38, 0.96);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s, visibility 0s 0.18s;
}
.lightbox.open { opacity: 1; visibility: visible; transition: opacity 0.18s; }
.lightbox img {
  display: block;
  max-width: min(100%, 1100px);
  max-height: 72vh;
  object-fit: contain;
  padding: clamp(6px, 1.4vw, 14px);
  background: #fff;
  transform: scale(0.97);
  transition: transform 0.22s ease;
}
.lightbox.open img { transform: none; }
.lightbox .cap { max-width: 42rem; margin-top: 18px; text-align: center; color: #eceef6; }
.lightbox .cap strong { display: block; font: 500 1.25rem / 1.25 var(--sans); }
.lightbox .cap time { display: block; margin-top: 2px; font: italic 400 1rem var(--serif); color: #a9aec8; }
.lightbox .cap p { margin: 10px 0 0; font: 400 1.05rem / 1.5 var(--serif); color: #d3d6e6; white-space: pre-wrap; }
.lb-count { position: absolute; top: 20px; left: 24px; font: 500 0.9rem var(--sans); color: #a9aec8; }
.lb-btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0 0 3px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: none;
  color: #fff;
  font: 400 1.7rem / 1 var(--sans);
  cursor: pointer;
}
.lb-btn:hover { background: rgba(255, 255, 255, 0.12); }
.lb-btn:focus-visible { outline-color: #fff; }
.lb-close { top: 14px; right: 18px; }
.lb-prev { left: 14px; top: 50%; margin-top: -23px; }
.lb-next { right: 14px; top: 50%; margin-top: -23px; }

/* ---------- Admin ---------- */
.admin-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 32px 0 14px; }
.admin-bar h1 { margin: 0; font: 600 clamp(1.8rem, 4vw, 2.4rem) / 1 var(--sans); letter-spacing: -0.03em; }
.admin-bar nav { display: flex; gap: 10px; }

.panel { margin-bottom: 24px; padding: clamp(16px, 3vw, 24px); background: var(--paper-2); border: 1px solid var(--line); }
.panel h2 { margin: 0 0 16px; font: 600 1.3rem / 1.2 var(--sans); letter-spacing: -0.02em; }
.login { max-width: 390px; margin: 14vh auto 0; }

label { display: block; margin-bottom: 5px; font: 500 0.9rem var(--sans); color: var(--ink-2); }
input[type='text'], input[type='password'], input[type='date'], textarea {
  width: 100%;
  padding: 10px 12px;
  font: 400 1rem var(--sans);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 3px;
}
input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea { min-height: 72px; resize: vertical; font-family: var(--serif); font-size: 1.05rem; }
.row { display: grid; grid-template-columns: 1fr 190px; gap: 14px; margin-bottom: 14px; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }
.field { margin-bottom: 14px; }

.btn {
  padding: 9px 18px;
  font: 500 1rem var(--sans);
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: 3px;
  cursor: pointer;
}
.btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.btn.primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: currentColor; }
.btn.small { padding: 5px 12px; font-size: 0.9rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
a.btn { display: inline-block; text-decoration: none; }

.drop {
  margin-bottom: 14px;
  padding: 34px 16px;
  text-align: center;
  color: var(--ink-3);
  border: 1.5px dashed var(--ink-3);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.drop.over, .drop:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.drop strong { color: var(--ink); font-weight: 600; }
.previews { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.previews .pv { position: relative; width: 84px; height: 84px; border: 1px solid var(--line); background: #fff; }
.previews img { display: block; width: 100%; height: 100%; object-fit: cover; }
.previews button {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; padding: 0;
  border: 0; border-radius: 50%; background: rgba(14, 18, 38, 0.8); color: #fff; line-height: 1; cursor: pointer;
}

.list { display: grid; gap: 12px; }
.item { display: grid; grid-template-columns: 90px 1fr auto; gap: 16px; align-items: center; padding: 10px; border: 1px solid var(--line); background: var(--paper); }
.item img { display: block; width: 90px; height: 90px; object-fit: cover; background: #fff; }
.item .info { min-width: 0; }
.item .info input { margin-bottom: 8px; }
.item .info .inline { display: flex; gap: 8px; }
.item .actions { display: flex; flex-direction: column; gap: 8px; }

.error { min-height: 1.3em; margin: 10px 0 0; font-size: 0.95rem; color: var(--danger); }

.toast {
  position: fixed; bottom: 24px; left: 50%; z-index: 100;
  padding: 10px 20px; font: 500 0.95rem var(--sans);
  color: var(--paper); background: var(--ink);
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  .month { grid-template-columns: 1fr; }
  .month-label { position: static; display: flex; align-items: baseline; gap: 12px; }
  .month-label p { margin: 0; }
  .month-label p span { display: inline; }
  .month-label p span + span::before { content: ', '; }
  .works { columns: 2 140px; column-gap: 16px; }
  .work { margin-bottom: 22px; }
  /* the year grid becomes a swipeable strip with comfortably sized dots */
  .gridinner { min-width: 560px; }
  .work .cap { flex-direction: column; gap: 2px; }
  .work time { margin-left: 0; }
  .item { grid-template-columns: 70px 1fr; }
  .item img { width: 70px; height: 70px; }
  .item .actions { grid-column: 1 / -1; flex-direction: row; }
  .lightbox { padding: 56px 12px 16px; }
  .lb-prev, .lb-next { top: auto; bottom: 18px; margin-top: 0; }
  .lb-prev { left: 18px; }
  .lb-next { right: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
