/* ==========================================================================
   LOVE JIGSAW PUZZLES - site.css
   One stylesheet for the home page and any page you build by hand.

   CONTENTS
     1. Colours and settings   (change the look of the whole site here)
     2. Base styles            (body text, links, pictures)
     3. Page layout            (.wrap, .section)
     4. Header and top menu    (the HTML is in /site/menu-top.html)
     5. Buttons
     6. Hero                   (the dark panel at the top of the home page)
     7. Section headings
     8. Banner grid            (holds your animated SSI banners)
     8b. Feature panel         (a wide panel: picture, text and a button)
     9. Picture cards          (a picture with a title underneath)
    10. Tiles                  (a small drawing with text beside it)
    11. Link list              (a row of small link buttons)
    12. Plain text block
    13. Footer                 (the HTML is in /site/menu-footer.html)
    14. Dark mode
    15. Reduced motion
    16. Speed                  (lets the browser leave off-screen sections until needed)

   The class names here do NOT start with "ljp-", so they can never clash
   with the banners, which all use "ljp-" names.
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. COLOURS AND SETTINGS
   Every colour on the page comes from this list. Change a value here and it
   changes everywhere. The first five match the Jigsaw Publisher pages.
   -------------------------------------------------------------------------- */
:root {
  --paper:   #faf7f2;   /* page background */
  --surface: #ffffff;   /* header, cards, menus */
  --ink:     #23201c;   /* main text */
  --dim:     #6d675e;   /* quieter text */
  --line:    #e7e1d7;   /* thin borders */

  --accent:  #17608a;   /* blue: buttons and borders on light backgrounds */
  --link:    #17608a;   /* blue: link text */
  --night:   #14324a;   /* dark blue: hero and footer background */
  --night-text: #d5e1ea; /* body text on the dark blue */
  --gold:    #f6b94a;   /* main button colour on the dark blue */
  --focus:   #17608a;   /* keyboard focus ring */

  --text-font:    system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --heading-font: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;

  --page-width: 1120px; /* widest the content gets */
  --gap:        24px;   /* space between cards, banners and tiles */
  --radius:     10px;   /* rounded corners */
  --shadow:     0 1px 2px rgba(35, 32, 28, 0.08), 0 6px 18px rgba(35, 32, 28, 0.07);
}


/* --------------------------------------------------------------------------
   2. BASE STYLES
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text-font);
  font-size: 1.0625rem;      /* 17px */
  line-height: 1.6;
}

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

a { color: var(--link); text-underline-offset: 3px; }
a:hover { color: var(--ink); }

h1, h2, h3 {
  font-family: var(--heading-font);
  font-weight: normal;
  line-height: 1.15;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0 0 1em; }

/* What a keyboard user sees when they Tab to a link or button */
a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

/* "Skip to content" link: hidden until a keyboard user tabs to it */
.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--surface);
  color: var(--ink);
  border-radius: 6px;
}
.skip-link:focus { top: 12px; }


/* --------------------------------------------------------------------------
   3. PAGE LAYOUT
   .wrap    keeps content centred and no wider than --page-width
   .section one horizontal band of the page
   -------------------------------------------------------------------------- */
.wrap {
  width: 100%;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 0 20px;
}

.section { padding: 56px 0; }

/* Add "section-tint" to a section for a white band with thin lines */
.section-tint {
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}


/* --------------------------------------------------------------------------
   4. HEADER AND TOP MENU
   -------------------------------------------------------------------------- */
.site-head {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 50;
}

.site-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  min-height: 64px;
}

/* The site name, top left */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--heading-font);
  font-size: 1.4rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand svg { width: 30px; height: 30px; flex: none; }
.brand:hover { color: var(--accent); }

/* The "Menu" button: only shown on phones (see the media query below) */
.menu-button {
  display: none;
  font: inherit;
  font-weight: 600;
  padding: 8px 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.top-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

/* A menu heading that opens a drop-down list */
.menu-group { position: relative; }

.menu-group summary,
.menu-link {
  display: block;
  padding: 10px 12px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 6px;
  cursor: pointer;
  list-style: none;            /* hides the browser's own triangle */
  white-space: nowrap;
}
.menu-group summary::-webkit-details-marker { display: none; }

/* The small arrow after each menu heading */
.menu-group summary::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-3px) rotate(45deg);
}
.menu-group[open] summary::after { transform: translateY(1px) rotate(225deg); }

.menu-group summary:hover,
.menu-link:hover,
.menu-group[open] summary { background: var(--paper); color: var(--ink); }

/* The drop-down list */
.menu-group ul {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 250px;
  margin: 6px 0 0;
  padding: 8px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
/* The last two drop-downs open leftwards so they stay on screen */
.menu-group:nth-last-child(-n+2) ul { left: auto; right: 0; }

.menu-group li a {
  display: block;
  padding: 8px 12px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 6px;
}
.menu-group li a:hover { background: var(--paper); color: var(--link); }

/* A small heading inside a drop-down list */
.menu-label {
  padding: 10px 12px 2px;
  font-size: 0.85rem;
  color: var(--dim);
}

/* Phones and small tablets: the menu folds away behind the Menu button */
@media (max-width: 899px) {
  .js .menu-button { display: block; }

  /* the site name shrinks a little on narrow phones so it stays on one line */
  .site-head-row { gap: 8px 12px; }
  .brand { font-size: clamp(1.05rem, 5vw, 1.4rem); gap: 6px; }
  .brand svg { width: 26px; height: 26px; }
  .menu-button { padding: 7px 14px; }

  .top-menu {
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-bottom: 12px;
  }
  .js .top-menu { display: none; }
  .js .top-menu.is-open { display: flex; }

  .menu-group summary,
  .menu-link { padding: 12px 8px; border-top: 1px solid var(--line); border-radius: 0; }

  .menu-group summary { display: flex; justify-content: space-between; align-items: center; }

  .menu-group ul,
  .menu-group:nth-last-child(-n+2) ul {
    position: static;
    min-width: 0;
    margin: 0 0 8px;
    padding: 0 0 0 12px;
    border: 0;
    box-shadow: none;
    background: none;
  }
}


/* --------------------------------------------------------------------------
   5. BUTTONS
   .button          gold, for the main action (made for dark backgrounds)
   .button-outline  a quieter second button
   -------------------------------------------------------------------------- */
.button {
  display: inline-block;
  padding: 13px 26px;
  font-weight: 600;
  line-height: 1.2;
  color: #23201c;
  background: var(--gold);
  border: 2px solid var(--gold);
  border-radius: 999px;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.button:hover { background: #ffd27a; border-color: #ffd27a; color: #23201c; }

.button-outline {
  color: #ffffff;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.55);
}
.button-outline:hover { background: #ffffff; border-color: #ffffff; color: #14324a; }


/* --------------------------------------------------------------------------
   6. HERO
   Text on the left, the jigsaw picture on the right.
   -------------------------------------------------------------------------- */
.hero {
  --focus: var(--gold);
  background: var(--night);
  color: #ffffff;
  overflow: hidden;
}

.hero-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 56px;
  align-items: center;
  padding-top: 56px;
  padding-bottom: 64px;
}

.hero h1 { font-size: clamp(2.1rem, 4.4vw, 3.4rem); line-height: 1.08; }

.hero-lede {
  margin: 20px 0 28px;
  max-width: 32em;
  font-size: 1.15rem;
  color: var(--night-text);
}

.hero-buttons { display: flex; flex-wrap: wrap; gap: 12px; }

/* The jigsaw picture. It is an SVG drawing in index.html. */
.hero-picture { position: relative; }

.hero-puzzle { display: block; transform: rotate(-1.5deg); }
.hero-puzzle svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 16px 28px rgba(0, 0, 0, 0.4));
}

.puzzle-board { fill: #0b2030; }          /* the dark board under the pieces */

/* One jigsaw piece. Each piece starts out of place (how far, and how far
   turned, is set on its own line in index.html) and slides home in turn.

   TO CHANGE THE SPEED, change the three numbers in the "animation" line:
       0.9s   how long one piece takes to slide home
       0.5s   the pause before the first piece moves
       0.26s  the gap between one piece starting and the next
   To switch the movement off altogether, delete the "animation" line. */
.puzzle-piece {
  fill: url(#hero-photo);
  stroke: rgba(8, 20, 30, 0.75);
  stroke-width: 2;
  stroke-linejoin: round;
  transform-box: fill-box;
  transform-origin: center;
  animation: piece-home 0.9s cubic-bezier(0.25, 0.9, 0.3, 1) calc(0.5s + var(--n) * 0.26s) both;
}
@keyframes piece-home {
  from { transform: translate(var(--x), var(--y)) rotate(var(--turn)); }
  to   { transform: translate(0, 0) rotate(0deg); }
}

/* The Replay button adds "is-reset" for an instant, which restarts the pieces */
.is-reset .puzzle-piece { animation: none; }

/* The small Replay button under the picture. It only shows when JavaScript
   is on, because it needs /site/site.js to work. */
.replay-button {
  display: none;
  align-items: center;
  gap: 6px;
  margin: 14px 0 0 auto;
  padding: 6px 14px 6px 10px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--night-text);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.js .replay-button { display: flex; }
.replay-button svg { width: 16px; height: 16px; }
.replay-button:hover { color: #14324a; background: #ffffff; border-color: #ffffff; }

@media (max-width: 820px) {
  .hero-row { grid-template-columns: 1fr; gap: 36px; padding-top: 40px; padding-bottom: 48px; }
  .hero-picture { max-width: 520px; }
}


/* --------------------------------------------------------------------------
   7. SECTION HEADINGS
   -------------------------------------------------------------------------- */
.section-title { font-size: clamp(1.7rem, 3vw, 2.3rem); }

.section-intro {
  margin: 10px 0 0;
  max-width: 62ch;
  color: var(--dim);
}

/* A smaller heading inside a section */
.sub-title { font-size: 1.4rem; margin-top: 48px; }

/* Space between a heading block and whatever follows it */
.section-title + .banner-grid,
.section-intro + .banner-grid,
.section-intro + .card-grid,
.section-intro + .tile-grid,
.section-intro + .link-list,
.sub-title + .card-grid,
.sub-title + .link-list { margin-top: 28px; }

.banner-grid + .tile-grid,
.banner-grid + .link-list,
.feature + .banner-grid { margin-top: var(--gap); }


/* --------------------------------------------------------------------------
   8. BANNER GRID
   Holds the animated banners that come in through SSI includes.
   Banners sit two to a row. Add "banner-wide" for a full-width banner.
   -------------------------------------------------------------------------- */
.banner-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
}

/* "display: flex" here, with "flex" on the banner link below, makes two
   banners that share a row the same height even when their text differs. */
.banner { display: flex; min-width: 0; }
.banner > a { flex: 1 1 auto; min-width: 0; }

.banner-wide { grid-column: 1 / -1; }

/* A centred, narrower banner (used for the Share banner) */
.banner-narrow { display: block; grid-column: 1 / -1; width: 100%; max-width: 640px; margin: 0 auto; }

/* The banners carry their own top and bottom margin. Inside the grid the
   gap does that job, so the margin is removed here. */
.banner-grid .banner > * { margin-top: 0; margin-bottom: 0; }

@media (max-width: 760px) {
  .banner-grid { grid-template-columns: 1fr; }
}


/* --------------------------------------------------------------------------
   8b. FEATURE PANEL
   A wide white panel for a section that has no animated banner yet.
   Picture on the left; heading, text, button and small links on the right.
   -------------------------------------------------------------------------- */
.feature {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  margin-top: var(--gap);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.feature-picture { display: block; }
.feature-picture img {
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--line);
}

.feature-body { align-self: center; padding: 32px 36px; }
.feature-body p { margin: 0 0 18px; }

.feature-title { font-size: 1.8rem; margin-bottom: 10px; }
.feature-text  { color: var(--dim); max-width: 54ch; }

/* the small links sit on a white panel here, so they get the page colour */
.feature .link-list a { background: var(--paper); }

@media (max-width: 760px) {
  .feature { grid-template-columns: 1fr; }
  .feature-picture img { aspect-ratio: 16 / 9; }
  .feature-body { padding: 24px 20px; }
}


/* --------------------------------------------------------------------------
   9. PICTURE CARDS
   A picture with a title and one line of text. The whole card is a link.
   The grid fits as many cards per row as there is room for.
   -------------------------------------------------------------------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--gap);
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 2px 4px rgba(35, 32, 28, 0.1), 0 12px 28px rgba(35, 32, 28, 0.14);
  color: var(--ink);
}

.card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--line);
}

.card-body { display: block; padding: 14px 16px 16px; }

.card-title {
  display: block;
  font-family: var(--heading-font);
  font-size: 1.2rem;
  line-height: 1.25;
}

.card-text {
  display: block;
  margin-top: 4px;
  font-size: 0.95rem;
  color: var(--dim);
}


/* --------------------------------------------------------------------------
   10. TILES
   A small drawing on the left, text on the right. Used for games and apps.
   -------------------------------------------------------------------------- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: var(--gap);
}

.tile {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s;
}
.tile:hover { border-color: var(--accent); color: var(--ink); }

/* Tiles on the plain page background are white instead */
.section:not(.section-tint) .tile { background: var(--surface); }

.tile-art { flex: none; width: 96px; height: 96px; border-radius: 8px; }

.tile-body { display: block; min-width: 0; }

.tile-title {
  display: block;
  font-family: var(--heading-font);
  font-size: 1.35rem;
  line-height: 1.2;
}

.tile-text {
  display: block;
  margin-top: 4px;
  font-size: 0.95rem;
  color: var(--dim);
}

.tile-go {
  display: inline-block;
  margin-top: 8px;
  font-weight: 600;
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 3px;
}


/* --------------------------------------------------------------------------
   11. LINK LIST
   A row of small rounded link buttons that wraps onto new lines.
   -------------------------------------------------------------------------- */
.link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.link-list a {
  display: block;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
}
.link-list a:hover { border-color: var(--accent); color: var(--link); }


/* --------------------------------------------------------------------------
   12. PLAIN TEXT BLOCK
   For ordinary paragraphs. Keeps lines a comfortable length to read.
   -------------------------------------------------------------------------- */
.text-block { max-width: 68ch; }
.text-block h2 { font-size: clamp(1.7rem, 3vw, 2.3rem); margin-bottom: 16px; }
.text-block h3 { font-size: 1.4rem; margin: 28px 0 10px; }
.text-block p:last-child { margin-bottom: 0; }


/* --------------------------------------------------------------------------
   13. FOOTER
   -------------------------------------------------------------------------- */
.site-foot {
  --focus: var(--gold);
  background: var(--night);
  color: var(--night-text);
  padding: 48px 0 32px;
  font-size: 0.97rem;
}

.site-foot a { color: #ffffff; text-decoration: none; }
.site-foot a:hover { color: var(--gold); text-decoration: underline; }

.foot-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 32px 24px;
}

.foot-title {
  font-family: var(--heading-font);
  font-size: 1.2rem;
  color: #ffffff;
  margin: 0 0 10px;
}

.foot-columns ul { margin: 0; padding: 0; list-style: none; }
.foot-columns li { margin: 0 0 6px; }

.foot-small {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.9rem;
}
.foot-small p { margin: 0 0 8px; max-width: 90ch; }
.foot-small a { text-decoration: underline; }


/* --------------------------------------------------------------------------
   14. DARK MODE
   Used automatically when the visitor's phone or computer is set to dark,
   the same as the Jigsaw Publisher pages. Only the colours change.
   Delete this whole block if you want the page to stay light.
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root {
    --paper:   #17181b;
    --surface: #1f2126;
    --ink:     #ece9e4;
    --dim:     #a09a90;
    --line:    #2c2f35;
    --accent:  #5aa3cc;
    --link:    #8cc4e6;
    --night:   #10283b;
    --focus:   #8cc4e6;
    --shadow:  0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.35);
  }
}


/* --------------------------------------------------------------------------
   15. REDUCED MOTION
   Visitors who have asked their device for less movement get none.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .puzzle-piece { animation: none; }
  .js .replay-button { display: none; }
  .card, .card:hover { transition: none; transform: none; }
}


/* --------------------------------------------------------------------------
   16. SPEED
   This does not change how anything looks. It tells the browser it may
   leave a section alone until the visitor scrolls near it, so the top of
   the page appears sooner and the banners further down do not use any
   power while they are off screen.

   "contain-intrinsic-size" is only a rough guess at a section's height
   (900px) for the scroll bar; the browser replaces it with the real height
   once it has drawn the section.

   If a section ever misbehaves, delete this block: the page works the same
   without it, just a little slower to appear.
   -------------------------------------------------------------------------- */
main > .section {
  content-visibility: auto;
  contain-intrinsic-size: auto 900px;
}
