/* ------------------------------------------------------------ colours and type */

:root {
  --paper: #f2f2f2; /* white, 5% darker */
  --ink: #1b1a17;
  --muted: #55534e;
  --placeholder: #e3e3e3;
  --tip: #f3e9d4; /* cream tooltip */
  --tip-ink: #1b1a17;
  --scroll-thumb: #d0d0d0; /* light but visible scrollbars */
  --track: #dedede; /* switches */
  --knob: #ffffff;
  --tab-shadow: -2px 2px 10px rgba(0, 0, 0, 0.16);
  --title-ink: var(--ink);
  --footer-ink: #a6a6a6; /* light grey */
  --font-title: "Jacquard 12 Charted", Georgia, serif;
  --font-tip: "Inconsolata", ui-monospace, Menlo, monospace;
  --font-text: "Helvetica Neue", Helvetica, Arimo, Arial, sans-serif;
  --tight: -0.025em; /* kerning -25 */
  --gap: 6.5px; /* space between photos on album pages */
  color-scheme: light;
}

/* Night mode: 95% black */
:root[data-scheme="dark"] {
  --paper: #0d0d0d;
  --ink: #e4e0d8;
  --muted: #9d998f;
  --placeholder: #1a1a19;
  --scroll-thumb: #3a3a38;
  --track: #262624;
  --knob: #4a4945;
  --tab-shadow: -2px 2px 12px rgba(255, 255, 255, 0.07);
  --title-ink: #666666; /* titles: 60% black */
  --footer-ink: #4d4d4d; /* dark grey */
  color-scheme: dark;
}

/* Language: only the text for the language picked with the EN/ES switch is shown. */
:root:not([data-lang="es"]) [data-l="es"],
:root[data-lang="es"] [data-l="en"] {
  display: none !important;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.6;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

/* Titles: Jacquard 12 Charted is a pixel font, so sizes are multiples of 12px to keep it crisp. */
h1 {
  color: var(--title-ink);
  font-family: var(--font-title);
  font-weight: 400;
  letter-spacing: var(--tight);
  line-height: 1.1;
}

/* Subheadings inside blog entries: bold Helvetica, not the title font */
h2,
h3 {
  font-family: var(--font-text);
  font-weight: 700;
  line-height: 1.25;
}

/* Text for screen readers only */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Short V arrows */
.chev {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.15em;
}
.chev-right {
  transform: scaleX(-1);
}

.back {
  display: inline-flex;
  align-items: center;
  min-width: 32px;
  min-height: 32px;
  color: var(--ink);
  font-size: 1.5rem;
  text-decoration: none;
}
.back:hover {
  opacity: 0.6;
}

/* ------------------------------------------------------------ scrollbars */

/* Chrome, Safari, Edge */
::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  background-clip: padding-box;
  border: 2px solid transparent;
  border-radius: 8px;
}
/* Firefox */
@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-color: var(--scroll-thumb) transparent;
  }
}

/* ------------------------------------------------------------ switches (night mode, EN/ES) */

.switches {
  display: flex;
  align-items: center;
  gap: 10px;
}
.switch {
  display: inline-flex;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.switch:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 3px;
  border-radius: 14px;
}
.switch-track {
  position: relative;
  display: block;
  width: 46px;
  height: 24px;
  border-radius: 12px;
  background: var(--track);
}
.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--knob);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}
.switch[aria-pressed="true"] .switch-knob {
  transform: translateX(22px);
}
/* The two sides: sun/moon or EN/ES. The active side sits on the knob. */
.switch-a,
.switch-b {
  position: absolute;
  top: 2px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  font: 700 9px/1 var(--font-text);
  letter-spacing: 0.02em;
  transition: opacity 0.2s ease;
}
.switch-a {
  left: 2px;
}
.switch-b {
  right: 2px;
}
.switch[aria-pressed="false"] .switch-b,
.switch[aria-pressed="true"] .switch-a {
  opacity: 0.4;
}
.sun,
.moon {
  width: 12px;
  height: 12px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}
.moon {
  stroke: none;
}

/* ------------------------------------------------------------ landing page */

/* Title centred, switches on the right of the same line. */
.masthead {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 30px 21px 0;
}
.masthead h1 {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  font-size: 24px;
  text-align: center;
}
.masthead .switches {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

/* Photos almost touch the sides, like on album pages. */
.albums {
  padding: 30px 7.5px 0;
}
.not-found {
  text-align: center;
}

/* Small line at the very bottom of the landing page */
.site-footer {
  padding: 56px 12px 28px;
  text-align: center;
  color: var(--footer-ink);
  font: 12px/1.4 var(--font-text);
}
.site-footer a {
  text-decoration: none;
}
.site-footer a:hover {
  text-decoration: underline;
}

/* Covers keep their own shape, so the columns end up uneven.
   Same space between photos as on album pages. */
.album-grid {
  --col-gap: var(--gap);
  --row-gap: var(--gap);
  display: flex;
  align-items: flex-start;
  gap: var(--col-gap);
}
.cover-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--row-gap);
}

.album-card a {
  position: relative;
  display: block;
  text-decoration: none;
}
.album-card img {
  width: 100%;
  background: var(--placeholder);
}
.album-card a:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 4px;
}

/* The album name is the tooltip (with a mouse); the caption is only read by screen readers.
   On phones and tablets nothing shows under the covers. */
.album-card .caption {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Tooltip with the album name (positioned by site.js) */
.tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  pointer-events: none;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--tip);
  color: var(--tip-ink);
  border-radius: 2px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  padding: 4px 11px 5px;
  font: 500 0.95rem/1.3 var(--font-tip);
  letter-spacing: var(--tight);
}
.tooltip[hidden] {
  display: none;
}

/* ------------------------------------------------------------ album page */

/* Desktop: the page itself doesn't scroll; photos and blog scroll separately. */
.album-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.album-head {
  flex: none;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 18px;
  padding: 12px 21px 10px;
}
.album-head .back,
.album-head .switches {
  align-self: center;
}
.album-head h1 {
  margin: 0;
  font-size: 36px;
}
.album-head .date {
  margin: 0;
  color: var(--muted);
}
.album-head .switches {
  margin-left: auto;
}

/* Notice when the blog isn't written in the language picked */
.blog-missing {
  flex-basis: 100%;
  order: 10;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.lang-switch {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
  cursor: pointer;
}

/* Width of the blog column, by number of photo columns */
.album {
  --diary-w: max(320px, 40vw);
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}
.album[data-columns="1"] {
  --diary-w: max(320px, 50vw);
}
.album[data-columns="3"] {
  --diary-w: max(320px, 33.333vw);
}
.album[data-columns="4"] {
  --diary-w: max(320px, 30vw);
}

/* No blog in the language picked: photos take the whole width. */
:root:not([data-lang="es"]) .album:not(.has-en) .diary,
:root:not([data-lang="es"]) .album:not(.has-en) .diary-tab,
:root[data-lang="es"] .album:not(.has-es) .diary,
:root[data-lang="es"] .album:not(.has-es) .diary-tab {
  display: none;
}

/* The photo side scrolls, but without a visible scrollbar. */
.photos {
  flex: 1 1 0;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  padding: 0 7.5px 7.5px;
}
.photos::-webkit-scrollbar {
  display: none;
}
.photo-grid {
  display: flex;
  align-items: flex-start;
  gap: var(--gap);
}
.photo-grid .col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
.photo {
  position: relative;
  margin: 0;
}
.photo img {
  width: 100%;
  background: var(--placeholder);
}

/* The blog slides closed to the right. Its text keeps its width while it slides. */
.diary {
  flex: none;
  width: var(--diary-w);
  overflow: hidden auto;
  overscroll-behavior: contain;
  transition: width 0.4s ease;
}
.diary-inner {
  width: var(--diary-w);
  padding: 4px clamp(18px, 2.25vw, 36px) 96px;
}
.album.diary-hidden .diary {
  width: 0;
}

.diary-hide {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 10px auto;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: 700 0.8rem/1 var(--font-text);
  cursor: pointer;
}
.diary-hide .chev {
  font-size: 1.05rem;
}
.diary-hide:hover {
  color: var(--ink);
}

/* Tab on the right edge that slides the blog back */
.diary-tab {
  position: fixed;
  top: 50%;
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px 16px 9px;
  border: 0;
  border-radius: 8px 0 0 8px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--tab-shadow);
  font: 400 0.85rem/1 var(--font-text);
  cursor: pointer;
  visibility: hidden;
  transform: translate(110%, -50%);
  transition: transform 0.3s ease, visibility 0.3s;
}
.diary-tab .chev {
  font-size: 1rem;
}
/* Reads from bottom to top */
.diary-tab span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
.album.diary-hidden .diary-tab {
  visibility: visible;
  transform: translate(0, -50%);
}
.diary-tab:hover {
  padding-right: 11px;
}

.diary-text > * {
  max-width: 36em;
}
.diary-text > :first-child {
  margin-top: 0;
}
.diary-text h2 {
  font-size: 1.1rem;
  margin: 1.8em 0 0.4em;
}
.diary-text h3 {
  font-size: 1rem;
  margin: 1.5em 0 0.3em;
}
.diary-text blockquote {
  margin: 1.2em 0;
  padding-left: 1em;
  border-left: 2px solid var(--ink);
  font-style: italic;
}
/* A "---" in a blog entry becomes extra space, not a line. */
.diary-text hr {
  border: 0;
  margin: 2.2em 0;
}
/* Drop cap on the first paragraph */
.diary-text > p:first-of-type::first-letter {
  float: left;
  color: var(--title-ink);
  font-family: var(--font-title);
  font-size: 48px;
  line-height: 0.85;
  padding: 0.04em 0.08em 0 0;
}

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

.photo-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
.photo-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 10px 21px 6px;
}
.photo-head .count {
  color: var(--muted);
  font-size: 0.9rem;
}

/* The photo fills the width, almost touching the sides. */
.photo-view {
  flex: 1;
  display: grid;
  align-items: start;
  padding: 4px 7.5px 7.5px;
}
.photo-view .big {
  margin: 0;
}
.photo-view .big img {
  width: 100%;
}
.photo-note {
  padding: 10px 14px 0;
  color: var(--muted);
  font-style: italic;
  font-size: 0.92rem;
  line-height: 1.5;
}
.photo-view.has-text {
  grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr);
  align-items: start;
  gap: 40px;
}
.photo-text {
  max-width: 36em;
}
.photo-text > :first-child {
  margin-top: 0;
}

.pager {
  display: flex;
  justify-content: space-between;
  padding: 8px 21px 20px;
}
.pager a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.pager a:hover {
  opacity: 0.6;
}

/* ------------------------------------------------------------ phones */

@media (max-width: 860px) {
  .masthead {
    padding: 16px 12px 0;
  }
  .albums {
    padding: 22px 6px 0;
  }
  .album-grid {
    --col-gap: 5px;
    --row-gap: 5px;
  }
  .site-footer {
    padding: 40px 12px 24px;
  }

  /* Album: one normal scrolling page. Blog first, then the photos in their original order. */
  .album-page {
    display: block;
    height: auto;
    overflow: visible;
  }
  .album-head {
    padding: 8px 14px 10px;
  }
  .album-head .switches {
    order: 1;
  }
  .album-head h1 {
    order: 2;
    flex-basis: 100%;
    font-size: 24px;
  }
  .album-head .date {
    order: 3;
  }
  .album {
    flex-direction: column;
  }
  .diary,
  .diary-inner {
    width: auto;
    overflow: visible;
    transition: none;
  }
  .diary {
    order: -1;
  }
  .diary-inner {
    padding: 4px 14px 26px;
  }
  .album.diary-hidden .diary {
    display: none;
  }
  .photos {
    overflow: visible;
    padding: 0 6px 6px;
  }
  .photo-grid {
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
  }
  .photo-grid .col {
    display: contents;
  }

  .photo-head {
    padding: 6px 14px 4px;
  }
  .photo-view,
  .photo-view.has-text {
    grid-template-columns: 1fr;
    padding: 6px;
    gap: 20px;
  }
  .photo-view .big {
    display: block;
    width: 100%;
  }
  .photo-view .big img {
    width: 100%;
    max-height: none;
  }
  .photo-note {
    display: block;
    padding: 10px 8px 0;
  }
  .photo-text {
    padding: 0 8px;
  }
  .pager {
    padding: 12px 14px 24px;
  }
}
