/* gregrob.ca site stylesheet
   Recreates the original look (browser-default serif text, centred pages,
   bordered photos, per-album backgrounds) with modern CSS, and makes pages
   fit phone screens. Album backgrounds live in backgrounds.css. */

@import url("backgrounds.css");

/* ---------- Base ---------- */

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

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

body {
  margin: 8px;
  font-family: "Times New Roman", Times, serif;
  line-height: 1.2;
  color: #000;
  background-color: #fff;
}

/* Photos shrink to fit narrow screens; width/height attributes keep their shape. */
img { max-width: 100%; height: auto; }

h1, h2 { margin: 0.67em 0; }

/* ---------- Page layout ---------- */

/* Replaces <center>: the whole page content is centred. */
.page { text-align: center; }

/* Replaces <center> blocks inside a page. */
.center { text-align: center; }

/* Replaces align="left|right" on images (text wraps around them). */
.float-left  { float: left;  margin-right: 3px; }
.float-right { float: right; margin-left: 3px; }

/* Red headings used on the home page and gallery title bars. */
.title-red { color: #f00; }

/* ---------- Photos ---------- */

/* A large photo, framed like the old border="2". The border takes the text
   colour, or the link colour when the photo is a link, as before. */
.photo { border: 2px solid; vertical-align: bottom; }

/* Thumbnails and small framed images (old border="1"). */
.thumb { border: 1px solid; vertical-align: bottom; }

.caption { margin: 0.5em auto; max-width: 60em; }

.downloads { margin: 1em auto; max-width: 50em; }

/* ---------- Previous / Up / Next ---------- */

.pager { margin: 1em 0; }
.pager a { white-space: nowrap; }
.pager .sep { margin: 0 0.25em; }

/* ---------- Thumbnail grids (index pages) ---------- */

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-start;
  margin: 1em 0;
}
.thumbs a { display: block; line-height: 0; }
.thumbs--center { justify-content: center; }

/* ---------- Footer (inc/footer.html) ---------- */

.site-footer {
  margin-top: 1.5em;
  text-align: center;
  font-size: smaller;
}
.site-footer small { font-size: smaller; }

/* ---------- Galleries (replace the old frames) ----------
   Layout: title bar across the top, thumbnail column on the left (like the
   old 140px left frame), photo on the right. On phones the thumbnail column
   becomes a horizontal strip under the title. */

.gallery {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);    /* the old left frame was 140px wide */
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "head head"
    "side main";
  margin: -8px;                        /* cancel body margin: the gallery fills the window */
  min-height: 100vh;
}

/* Title bar (old top frame); keeps that frame's own background class. */
.gallery-head {
  grid-area: head;
  text-align: center;
  padding: 4px 8px;
}
.gallery-head h1 { margin: 0.3em 0; }

/* Thumbnail column (old left frame); its background runs the full height,
   while the list itself stays in view as the photo scrolls. */
.gallery-side { grid-area: side; min-width: 0; }
.gallery-side ul {
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.gallery-side li.pic { line-height: 0; }
.gallery-side li.text { line-height: 1.2; text-align: center; }

.gallery-main {
  grid-area: main;
  text-align: center;
  padding: 8px;
  min-width: 0;                        /* let wide photos shrink inside the grid */
}

/* Phones: thumbnails become a swipeable strip under the title. */
@media (max-width: 640px) {
  .gallery {
    grid-template-columns: minmax(0, 1fr);   /* never wider than the screen */
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "head"
      "side"
      "main";
  }
  .gallery-side ul {
    position: static;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    flex-direction: row;
    align-items: center;
    padding: 4px 8px;
  }
  .gallery-side li { flex: 0 0 auto; }
  .gallery-side li.text { max-width: 9em; }
  .gallery-side img { max-width: none; height: 75px; width: auto; }
}

/* ---------- Tables kept for real tabular data (e.g. the daily calendar) ---------- */

.calendar { margin: 0 auto; border-collapse: collapse; }
.calendar td, .calendar th { border: 1px solid #000; padding: 2px; vertical-align: top; }
.calendar .nav td { vertical-align: middle; text-align: center; }
.calendar .month { font-size: larger; font-weight: bold; }
.calendar img { max-width: none; }
.calendar-wrap { overflow-x: auto; }
.calendar th { font-weight: bold; }

/* ---------- Text pages ---------- */

/* Long-form text with side margins (replaces a spacer table, e.g. ago_story.html). */
.story { margin: 0 min(72px, 5vw); }

/* Embedded videos scale with the screen. */
.video { display: block; margin: 1em auto; width: 100%; max-width: 640px; height: auto; aspect-ratio: 16 / 9; border: 0; }

/* Before / label / after comparisons (photoshop pages; replaces layout tables). */
.compare {
  display: grid;
  grid-template-columns: auto auto auto;
  justify-content: center;
  align-items: center;
  gap: 4px 8px;
  margin: 0 0 3em;
}
.compare figure { margin: 0; text-align: center; }
.compare figcaption { margin-top: 2px; }
.compare-label { text-align: center; font-weight: bold; }
@media (max-width: 720px) {
  .compare { grid-template-columns: 1fr; }
  .compare-label { order: -1; }
}

/* Photos side by side with captions (replaces small layout tables). */
.cards { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 1em 50px; margin: 1em 0; }
.card { text-align: center; }
