/* Public pages: photostream, albums, album, photo, tag. Admin pages keep
   Bootstrap (layouts/main.njk); nothing here touches them. */

:root {
  --bg: #ffffff;
  --fg: #212124;
  --muted: #6b6b70;
  --line: #e4e4e7;
  --link: #0a66c2;
  --chip: #f0f0f2;
  --bar: #121214;
  --bar-fg: #f4f4f5;
  --bar-muted: #a1a1aa;
  --stage: #0d0d0e;
  --tile-bg: #e9e9ec;
  --row-h: 240px;
  --gap: 4px;
  --gutter: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18181b;
    --fg: #ececee;
    --muted: #a1a1aa;
    --line: #2e2e33;
    --link: #6cb2ff;
    --chip: #27272a;
    --tile-bg: #26262a;
  }
}

@media (max-width: 900px) { :root { --row-h: 180px; } }
@media (max-width: 560px) { :root { --row-h: 130px; --gap: 2px; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 var(--font);
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { line-height: 1.2; }

/* ---------------------------- top bar ---------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bar);
  color: var(--bar-fg);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 52px;
  padding: 0 var(--gutter);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--bar-fg);
  font-weight: 650;
  font-size: 17px;
  white-space: nowrap;
}
.brand-mark { font-size: 20px; font-weight: 700; letter-spacing: 0.02em; }
.brand-logo { display: block; height: 32px; width: auto; }
.brand-title { overflow: hidden; text-overflow: ellipsis; }
.brand:hover { text-decoration: none; }
.tabs { display: flex; gap: 4px; height: 100%; }
.tabs a {
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: var(--bar-muted);
  border-bottom: 3px solid transparent;
  border-top: 3px solid transparent;
}
.tabs a:hover { color: var(--bar-fg); text-decoration: none; }
.tabs a.active { color: var(--bar-fg); border-bottom-color: var(--bar-fg); }
.spacer { flex: 1; }
.login { color: var(--bar-fg); white-space: nowrap; }
.bar-link { color: var(--bar-fg); white-space: nowrap; padding: 6px 10px; border-radius: 6px; }
.bar-link:hover { background: #2a2a2e; text-decoration: none; }

.menu { position: relative; }
.menu summary {
  list-style: none;
  cursor: pointer;
  color: var(--bar-fg);
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: " \25BE"; color: var(--bar-muted); }
.menu[open] summary, .menu summary:hover { background: #2a2a2e; }
.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 200px;
  padding: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.menu-list a, .menu-list button {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.menu-list a:hover, .menu-list button:hover { background: var(--chip); text-decoration: none; }
.menu-list hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu-list form { margin: 0; }

@media (max-width: 560px) {
  .topbar-inner { gap: 10px; }
  .tabs a { padding: 0 8px; }
  .brand { font-size: 15px; }
}

/* ---------------------------- headings ---------------------------- */

.profile { padding: 28px var(--gutter) 18px; }
.profile h1 { margin: 0 0 4px; font-size: 30px; font-weight: 700; }
.counts { margin: 0; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.counts .dot { color: var(--muted); }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.eyebrow a { color: inherit; }
.empty { padding: 40px var(--gutter); color: var(--muted); }
.notfound p { color: var(--muted); }

.button {
  display: inline-block;
  padding: 5px 14px;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: inherit;
  font-size: 14px;
}
.button:hover { text-decoration: none; background: rgba(127, 127, 127, 0.15); }

/* ---------------------------- justified grid ----------------------------
   Each tile's flex-basis is its width at the row height, and it grows by an
   amount proportional to its aspect ratio, so every tile in a row gains the
   same height. The <i> holds the tile's shape; the image fills it. The
   ::after filler soaks up the last row's space, so it isn't stretched. */

.jgrid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  padding: 0 var(--gutter);
}
.jgrid::after { content: ""; flex-grow: 999999999; }
.tile {
  position: relative;
  display: block;
  flex-grow: calc(var(--ar) * 100);
  flex-basis: calc(var(--ar) * var(--row-h));
  /* Never wider than the screen, and not blown up past twice the row height */
  max-width: 100%;
  max-height: calc(var(--row-h) * 2);
  overflow: hidden;
  background: var(--tile-bg);
}
.tile > i { display: block; }
.tile > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Pick stars, in a tile's upper left. Gold when picked; an unpicked star
   (only a customer picking sees those) is a faint outline until hovered. */
.pick {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: rgba(255, 255, 255, 0.85);
  cursor: default;
}
.pick svg, .pick-glyph svg { display: block; flex: none; width: 22px; height: 22px; fill: currentColor; }
.pick-glyph svg { width: 18px; height: 18px; }
.pick-glyph { display: inline-flex; vertical-align: -3px; }
.pick[role="button"] { cursor: pointer; opacity: 0.55; transition: opacity 0.15s, transform 0.1s; }
.tile:hover .pick[role="button"], .pick[role="button"]:focus-visible { opacity: 1; }
.pick[role="button"]:active { transform: scale(0.9); }
.pick.on { color: #ffc531; opacity: 1; background: rgba(0, 0, 0, 0.5); }
@media (hover: none) { .pick[role="button"] { opacity: 0.85; } }

.pick-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 14px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
}
.pick-button:hover { background: var(--chip); }
.pick-button.on { border-color: #e0a800; }
.pick-glyph { color: var(--muted); }
.pick-button.on .pick-glyph, .picked-by .pick-glyph { color: #e0a800; }
.picked-by { margin: 0 0 12px; color: var(--muted); }

.tile-title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 24px 10px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
  color: #fff;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.15s;
}
.tile:hover .tile-title, .tile:focus-visible .tile-title { opacity: 1; }
.tile:hover { text-decoration: none; }
@media (hover: none) { .tile-title { display: none; } }

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 520px;
  margin: 28px auto 40px;
  padding: 0 var(--gutter);
}
.pager-pos { color: var(--muted); }

/* ---------------------------- albums ---------------------------- */

/* Albums: the same justified rows as the photostream, so every cover keeps
   its own shape, with the title and count over it and wide gutters */
.album-grid {
  --album-h: 220px;
  display: flex;
  flex-wrap: wrap;
  gap: 32px 24px;
  padding: 8px var(--gutter) 48px;
}
.album-grid::after { content: ""; flex-grow: 999999999; }
.album-card {
  display: flex;
  flex-direction: column;
  flex-grow: calc(var(--ar) * 100);
  flex-basis: calc(var(--ar) * var(--album-h));
  max-width: 100%;
  min-width: 0;
  color: #fff;
}
.album-card:hover { text-decoration: none; }
.album-card-img {
  position: relative;
  display: block;
  /* Not stretched past half again the row height on a short last row */
  max-height: calc(var(--album-h) * 1.5);
  overflow: hidden;
  border-radius: 4px;
  background: var(--tile-bg);
}
.album-card-img > i { display: block; }
.album-card-img > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}
.album-card:hover img { transform: scale(1.03); }
.album-card-text {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  padding: 36px 12px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
  color: #fff;
}
.album-card-title { font-weight: 650; font-size: 16px; line-height: 1.25; }
.album-card-count { margin-top: 2px; font-size: 13px; opacity: 0.85; }
@media (max-width: 900px) { .album-grid { --album-h: 170px; gap: 28px 18px; } }
@media (max-width: 560px) { .album-grid { --album-h: 120px; gap: 24px 12px; } }

.album-hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 300px;
  margin-bottom: 16px;
  overflow: hidden;
  background: #2a2a2e;
  color: #fff;
}
.album-hero.no-cover { min-height: 0; background: none; color: var(--fg); }
.album-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.album-hero:not(.no-cover)::after {
  content: "";
  position: absolute;
  inset: 0;
  /* Flickr's banner gradient: clear through the top fifth, so the photo
     keeps its contrast, then easing dark behind the title */
  background: linear-gradient(180deg, transparent 0, rgba(0, 0, 0, 0.03) 8%, rgba(0, 0, 0, 0.11) 21%,
    rgba(0, 0, 0, 0.61) 78%, rgba(0, 0, 0, 0.7) 95%, rgba(0, 0, 0, 0.7));
}
.album-hero-text {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 900px;
  padding: 28px var(--gutter) 22px;
}
.album-hero h1 { margin: 0 0 6px; font-size: 34px; }
.album-hero .eyebrow, .album-hero:not(.no-cover) .counts { color: rgba(255, 255, 255, 0.85); }
.album-hero:not(.no-cover) a { color: #fff; }
.album-desc { margin: 0 0 10px; max-width: 70ch; }
/* The profile banner on the photostream and Albums pages. The gradient is
   Flickr's: clear at the top, easing to 70% black at the bottom. The subject
   sits left of center, so keep it in frame when a narrow screen crops. */
.profile-banner {
  position: relative;
  display: flex;
  align-items: flex-end;
  height: 280px;
  overflow: hidden;
  background: #000;
  color: #fff;
}
.profile-banner img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 30% 50%;
}
.profile-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0, rgba(0, 0, 0, 0.03) 8%, rgba(0, 0, 0, 0.11) 21%,
    rgba(0, 0, 0, 0.61) 78%, rgba(0, 0, 0, 0.7) 95%, rgba(0, 0, 0, 0.7));
}
.profile-banner h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0 var(--gutter) 20px;
  font-size: 34px;
  font-weight: 700;
}
.banner-counts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
  padding: 14px var(--gutter) 18px;
}

/* An on/off switch that is really a link: the page reloads filtered */
.switch { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.switch:hover { text-decoration: none; color: var(--fg); }
.switch-track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 10px;
  background: rgba(127, 127, 127, 0.4);
  transition: background 0.15s;
}
.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: left 0.15s;
}
.switch.on { color: var(--fg); }
.switch.on .switch-track { background: var(--link); }
.switch.on .switch-knob { left: 16px; }
@media (max-width: 560px) {
  .profile-banner { height: 180px; }
  .profile-banner h1 { font-size: 26px; }
}
@media (max-width: 560px) {
  .album-hero { min-height: 220px; }
  .album-hero h1 { font-size: 26px; }
}

/* ---------------------------- photo page ---------------------------- */

.stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(100vh - 52px);
  min-height: 320px;
  max-height: 1400px;
  background: var(--stage);
  overflow: hidden;
}
.stage-img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 120px);
  width: auto;
  height: auto;
  object-fit: contain;
}
.stage-back, .stage-pos {
  position: absolute;
  top: 14px;
  z-index: 2;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #e4e4e7;
  font-size: 14px;
}
.stage-back { left: 14px; }
.stage-back:hover { color: #fff; text-decoration: none; background: rgba(0, 0, 0, 0.7); }
.stage-pos { right: 14px; }
.stage-nav {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  width: 18%;
  max-width: 160px;
  padding: 0 16px;
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s;
}
.stage:hover .stage-nav, .stage-nav:focus-visible { opacity: 0.85; }
.stage-nav:hover { opacity: 1; text-decoration: none; }
.stage-nav.prev { left: 0; justify-content: flex-start; }
.stage-nav.next { right: 0; justify-content: flex-end; }
.stage-nav span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  font-size: 34px;
  line-height: 1;
}
@media (hover: none) { .stage-nav { opacity: 0.8; } }
@media (max-width: 560px) {
  .stage { height: auto; min-height: 0; padding: 48px 0 12px; }
  .stage-img { max-height: 75vh; }
  .stage-nav { width: 22%; padding: 0 6px; }
  .stage-nav span { width: 36px; height: 36px; font-size: 26px; }
}

.photo-info {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 40px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px var(--gutter) 60px;
}
@media (max-width: 800px) { .photo-info { grid-template-columns: 1fr; gap: 16px; } }
.photo-main h1 { margin: 0 0 10px; font-size: 26px; overflow-wrap: anywhere; }
.photo-main h2, .photo-side h2 {
  margin: 24px 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.photo-desc { overflow-wrap: anywhere; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 0; padding: 0; list-style: none; }
.tags a {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--fg);
  font-size: 13px;
}
.tags a:hover { text-decoration: none; filter: brightness(0.95); }
.in-albums, .sizes { margin: 0; padding: 0; list-style: none; }
.in-albums li, .sizes li { padding: 3px 0; }

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  margin: 0;
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* ---------------------------- footer and text pages ---------------------------- */

.site-footer {
  display: flex;
  gap: 18px;
  justify-content: center;
  padding: 28px var(--gutter) 36px;
  font-size: 13px;
}
.site-footer a { color: var(--muted); }
.doc { max-width: 70ch; margin: 0 auto; padding: 28px var(--gutter) 8px; line-height: 1.55; }
.doc h1 { margin: 0 0 4px; font-size: 30px; }
.doc h2 { margin: 28px 0 6px; font-size: 19px; }
.doc p { margin: 0 0 12px; }
.doc-date { color: var(--muted); font-size: 14px; }

/* ---------------------------- comments ---------------------------- */

.comments { margin-top: 24px; }
.comment { padding: 12px 0; border-top: 1px solid var(--line); }
.comment header { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.comment-when { color: var(--muted); font-size: 13px; }
.comment-body { margin-top: 4px; overflow-wrap: anywhere; }
.comment-actions { display: flex; gap: 14px; align-items: flex-start; margin-top: 6px; font-size: 13px; }
.comment-actions summary { cursor: pointer; color: var(--link); }
.comment-actions form { margin: 6px 0 0; }
.comment-delete { margin: 0 !important; }
.comment-actions button, .comment-delete button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font: inherit;
  cursor: pointer;
}
.comment-form { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.comment-form label { font-weight: 600; }
.comments textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  resize: vertical;
}
.comment-form button, .comment-actions details button {
  align-self: flex-start;
  padding: 6px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--chip);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
}
.comment-error { color: #c0392b; }

/* ---------------------------- installed app ---------------------------- */

/* The installed app draws under the phone's status bar and around the
   notch, so the bar and the page keep clear of them */
.topbar { padding-top: env(safe-area-inset-top); }
.topbar-inner, .site-footer {
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}
.site-footer { padding-bottom: max(36px, env(safe-area-inset-bottom)); }

/* ---------------------------- notifications page ---------------------------- */

.notify-page section { margin-top: 24px; }
.notify-card { padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; }
.notify-card h2 { margin-top: 0; }
.notify-prefs fieldset { margin: 0 0 16px; padding: 0; border: 0; }
.notify-prefs legend { margin-bottom: 6px; font-weight: 650; }
.notify-prefs label { display: flex; gap: 8px; align-items: baseline; margin: 6px 0; }
.notify-albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }
.notify-help, .notify-status { color: var(--muted); font-size: 14px; }
.notify-saved { color: #2e7d32; }
.button-solid, .button-plain {
  margin: 4px 8px 4px 0;
  padding: 8px 18px;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
}
.button-solid { border: 0; background: var(--link); color: #fff; }
.button-plain { border: 1px solid var(--line); background: var(--chip); color: var(--fg); }
