/* ============================================================================
   EarthToTommy.com  |  SITE STYLESHEET
   ============================================================================

   HOW THIS FILE WORKS

   This is the ONLY stylesheet to edit. Bootstrap loads first, this loads
   second, so anything in here wins. Never edit the Bootstrap file itself -
   if you do, you can never update Bootstrap without losing your work. That
   is what happened with the old bootstrap-4.4.1.css, which had custom rules
   scattered through 10,000 lines of framework code.

   Everything custom from that old file has been carried over here, in
   plain sight, with notes.

   WHERE TO CHANGE THINGS
     Section 1   Colours and fonts - change the palette in ONE place
     Section 2   Typography scale
     Section 3   Accessibility defaults (focus, motion, target size)
     Section 4   Header and credentials line
     Section 5   Navigation - desktop and mobile
     Section 6   Footer
     Section 7   Page content helpers

   ============================================================================ */


/* ============================================================================
   SECTION 1 - THEME
   ============================================================================
   Bootstrap 5.3 exposes its whole theme as CSS variables. Override them here
   and the change flows through every component. This is the Bootstrap 5 way
   of theming, and it means the examples on getbootstrap.com work as written.

   CONTRAST NOTE
   Three colours from the old stylesheet failed WCAG contrast and have been
   darkened. Text needs 4.5:1 against its background. Large text (24px, or
   18.5px bold) needs 3:1.

     was #859e80 sage green   2.92:1  FAILED  ->  now #54704F  5.52:1  passes
     was #007bff link blue    3.98:1  FAILED  ->  now #0B5FA5  6.57:1  passes

   Both replacements keep the original hue and just pull the lightness down.
   If you want to adjust them, test at webaim.org/resources/contrastchecker
   before shipping.
   ============================================================================ */

:root {
  /* Brand colours */
  --et-green:        #54704F;   /* links, primary accent */
  --et-green-dark:   #405C3C;   /* link hover */
  --et-blue:         #0B5FA5;   /* secondary accent, footer links */
  --et-blue-dark:    #08487D;   /* footer link hover */
  --et-ink:          #333333;   /* body text */
  --et-band:         #f8f9fa;   /* nav bar background */

  /* Hand these to Bootstrap so its components inherit them */
  --bs-body-color:        var(--et-ink);
  --bs-body-font-family:  rucksack, sans-serif;
  --bs-link-color:        var(--et-green);
  --bs-link-hover-color:  var(--et-green-dark);
  --bs-link-color-rgb:    84, 112, 79;
}

body {
  font-family: rucksack, sans-serif;
  font-weight: 400;
  font-style: normal;
  line-height: 1.4;
  color: var(--et-ink);
}

/* Links. Underline on hover and focus rather than colour alone - colour by
   itself is not enough to distinguish a link for someone with low vision or
   colour blindness. */
a {
  color: var(--et-green);
  text-decoration: none;
  font-weight: 500;
}
a:hover,
a:focus-visible {
  color: var(--et-green-dark);
  text-decoration: underline;
}

/* Bootstrap's .text-primary was stock blue and failed contrast. */
.text-primary {
  color: var(--et-blue) !important;
}


/* ============================================================================
   SECTION 2 - TYPOGRAPHY
   ============================================================================
   Carried over from the old stylesheet.

   READ THIS BEFORE CHANGING SIZES
   These are percentages of the browser's base size, normally 16px.
   So font-size: 75% renders at about 12px.

   Paragraph text is currently 75%, which is roughly 12px. That is on the
   small side for body copy. It is not a WCAG failure - there is no minimum
   font size in the standard, and the page scales correctly when zoomed - but
   it is worth looking at on a real screen. 87.5% would give you 14px and
   would read more comfortably for most people. Left at 75% for now because
   it is a design decision, not a compliance one.

   Percentages nest. A .small inside a <p> compounds both, which gets tiny
   quickly. Worth watching.
   ============================================================================ */

p {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 75%;            /* ~12px - see note above */
  letter-spacing: 0.0725em;
}

/* Size helpers, largest to smallest */
.lead     { margin-top: 0; font-size: 90%; letter-spacing: 0.05em;   font-family: rucksack, sans-serif; font-style: normal; font-weight: 400; }
.large    { margin-top: 0; font-size: 85%; letter-spacing: 0.05em;   font-family: rucksack, sans-serif; font-style: normal; font-weight: 400; }
.medium   { margin-top: 0; margin-bottom: 0.75rem; font-size: 75%; font-weight: 400; letter-spacing: 0.0725em; }
.small    { font-size: 70%; font-weight: 400; letter-spacing: 0.0725em; }
.xsmall   { font-size: 65%; font-weight: 400; letter-spacing: 0.0725em; }
.xxsmall  { font-size: 60%; font-weight: 400; letter-spacing: 0.0725em; }

/* Utility: slightly looser line height */
.lh-md    { line-height: 1.375; }

/* Utility: extra letter-spacing */
.spaced   { letter-spacing: 0.05em !important; }


/* ----------------------------------------------------------------------------
   HEADING SCALE

   IMPORTANT FIX
   In the old stylesheet h1 was set to 1rem while h2 was 1.75rem, so an <h1>
   rendered SMALLER than an <h2>. That almost certainly explains why some page
   headings ended up marked as <h1> - that was the level that looked right.

   Heading level and visual size are separate things. The level says where the
   item sits in the page outline, which is how screen reader users navigate.
   The size is just appearance. They should agree, and now they do.

   Each page has exactly one <h1>. Section headings below it are <h2>, and so
   on down. Never skip a level to get a size - change the size here instead.
   ---------------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  margin-top: 0;
  margin-bottom: 0.25rem;
  letter-spacing: 0.02em;
  font-weight: 500;
  line-height: 1.1;
}

h1, .h1 { font-size: 2rem; }      /* was 1rem - smaller than h2, now corrected */
h2, .h2 { font-size: 1.5rem; }
h3, .h3 { font-size: 1.25rem; }
h4, .h4 { font-size: 1.125rem; }
h5, .h5 { font-size: 1rem; }
h6, .h6 { font-size: 0.9375rem; }

hr {
  margin-top: 1rem;
  margin-bottom: 1rem;
  border: 0;
  border-top: 0.5px solid rgba(0, 0, 0, 0.1);
}


/* ============================================================================
   SECTION 3 - ACCESSIBILITY DEFAULTS
   ============================================================================
   These are the rules that make the site usable by keyboard and by people
   with vision or motion sensitivities. Nothing here should need changing,
   but here is what each one does in case you need to work around it.
   ============================================================================ */

/* FOCUS
   The single most important rule in this file.

   In the old stylesheet, :hover and :focus on dropdown items shared one
   declaration with a very faint grey background. That meant a keyboard user
   tabbing through the menu got the same nearly-invisible cue as a mouse user
   hovering - and could easily lose track of where they were.

   Focus and hover are now deliberately different. Hover gets a background
   tint. Focus gets a background tint AND a solid outline, because an outline
   reads instantly in a way a fill does not.

   :focus-visible means the outline shows for keyboard users but not when
   clicking with a mouse, which is the modern behaviour people expect.

   NEVER write "outline: none" anywhere. That is an instant WCAG failure. */

:focus-visible {
  outline: 3px solid var(--et-blue);
  outline-offset: 2px;
}

/* Skip link. Hidden until focused, then appears top-left. */
.skip-link:focus {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 1080;
  padding: 0.75rem 1.25rem;
  background: #ffffff;
  color: var(--et-ink);
  border: 2px solid var(--et-blue);
  border-radius: 0.25rem;
  font-weight: 600;
}

/* REDUCED MOTION
   Some people get motion sickness or migraines from animation. The operating
   system lets them ask for less of it, and this respects that request. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* TARGET SIZE
   WCAG 2.2 requires interactive controls to be at least 24 by 24 pixels, so
   people with tremor or limited dexterity can hit them. The social icons and
   footer links are the ones most at risk. */
.social-icons .nav-link,
.footer-sitemap .nav-link,
.footer-legal a {
  min-height: 24px;
  display: inline-block;
}

/* Images never overflow their container at any zoom level. */
img { max-width: 100%; height: auto; }


/* ============================================================================
   SECTION 4 - HEADER
   ============================================================================ */

/* Credentials line under the logo.
   Mixed case rather than caps: all caps runs 12-15% wider, which matters on a
   phone, and "PH.D." loses the visual cue that it is an abbreviation.
   Each segment is wrapped in .nowrap in the HTML so phrases never split. */
.site-credentials {
  text-transform: none;
  letter-spacing: 0.04em;
  line-height: 1.5;
  color: var(--et-ink);
  font-size: 0.875rem;       /* 14px */
}
.site-credentials .nowrap { white-space: nowrap; }
.site-credentials .sep    { padding: 0 0.35em; }

/* The name in the credentials line links to the About page.

   IT IS DELIBERATELY NOT OBVIOUS. It stays the same dark colour as the text
   beside it, with no underline until hovered or focused. That is a design
   choice to keep the header line clean, and it is safe for three reasons:

     - Nothing here relies on colour alone to mark a link, which is the thing
       WCAG actually prohibits. This link carries no colour signal at all.
     - Keyboard users still get the focus ring from Section 3.
     - The About page is reachable two other ways on every page: the footer
       site map, and the Welcome card on the home page. The header link is a
       shortcut for people who find it, not the only route.

   No extra padding is needed for target size. WCAG 2.2's minimum target size
   has an exception for links inside a sentence, where the line height sets
   the size, and this qualifies. */
.site-credentials .credentials-link {
  color: inherit;
  font-weight: inherit;
  text-decoration: none;
}
.site-credentials .credentials-link:hover,
.site-credentials .credentials-link:focus-visible {
  color: var(--et-green-dark);
  text-decoration: underline;
}

.social-icons .nav-link { color: var(--et-ink); }
.social-icons .nav-link:hover,
.social-icons .nav-link:focus-visible { color: var(--et-green); }


/* ============================================================================
   SECTION 5 - NAVIGATION
   ============================================================================
   CASE
   Top-level bar stays uppercase. Short items, good letter-spacing, reads as
   navigation.

   Dropdown items are now mixed case. Longer phrases like "What We're Building"
   lose the ascenders and descenders that let people read by word shape when
   set in caps, and the apostrophe gets visually lost. Caps on the bar, mixed
   case in the menus, is a common and readable pattern.

   SIZE
   Both were around 11-12px before. Now 14px minimum. Small caps text on an
   interactive control is hard to read and hard to hit.
   ============================================================================ */

.navbar-nav {
  font-family: rucksack, sans-serif;
  font-weight: 600;
  font-style: normal;
  font-size: 0.875rem;       /* 14px */
  text-transform: uppercase;
  letter-spacing: 0.0925em;
}

.navbar-nav .nav-link {
  color: var(--et-ink);
  padding: 0.5rem 0.75rem;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link:focus-visible,
.navbar-nav .nav-link.show {
  color: var(--et-green);
}

/* Marks where you are in the site. The short script at the bottom of
   main.dwt sets these automatically by reading the page's address, so
   nothing has to be added by hand on any page.

   Two values, and they mean different things:
     aria-current="page"   this IS the page you are on
     aria-current="true"   this is the SECTION the page belongs to

   The selector matches any value, so both get the same styling. If you ever
   want the section styled more lightly than the exact page, split this into
   two rules on [aria-current="page"] and [aria-current="true"]. */
.navbar-nav .nav-link[aria-current] {
  color: var(--et-green);
  font-weight: 700;
}

/* Same marker on the items inside a dropdown, where it lands on the exact
   page. Lighter than the top-level version so the open menu does not end up
   with two things shouting at once. */
.dropdown-item[aria-current="page"] {
  color: var(--et-green-dark);
  font-weight: 600;
}

/* Pipe separators between top-level items.
   Drawn with CSS rather than real characters so screen readers never announce
   them. Hidden on mobile, where items are stacked. */
@media (min-width: 992px) {
  .navbar-nav > .nav-item:not(:last-child)::after {
    content: "|";
    color: #cccccc;
    align-self: center;
    padding: 0 0.25rem;
  }
  .navbar-nav > .nav-item { display: flex; }
}

/* DROPDOWN MENUS */
.dropdown-item {
  font-family: rucksack, sans-serif;
  font-weight: 500;
  font-size: 0.875rem;       /* 14px */
  text-transform: none;      /* mixed case - see note at top of section */
  letter-spacing: 0.02em;
  color: var(--et-ink);
  padding: 0.6rem 1.5rem;    /* comfortable target height */
}

/* Hover: background tint AND a colour change, so it is not carried by fill
   alone. The old version was a very pale grey with no text change and was
   nearly invisible on a bright screen. */
.dropdown-item:hover {
  background-color: #EDF2EC;
  color: var(--et-green-dark);
}

/* Focus: deliberately stronger than hover, with an outline. This is what a
   keyboard user sees, and they need to spot it at a glance. */
.dropdown-item:focus,
.dropdown-item:focus-visible {
  background-color: #EDF2EC;
  color: var(--et-green-dark);
  outline: 2px solid var(--et-blue);
  outline-offset: -2px;
}

.dropdown-item.active,
.dropdown-item:active {
  background-color: var(--et-green);
  color: #ffffff;
}

/* MOBILE
   Below 992px the navbar collapses to the hamburger. Items become full-width
   rows, big enough to tap reliably, and in mixed case since there is room. */
@media (max-width: 991.98px) {
  .navbar-nav { text-transform: none; font-size: 1rem; }

  .navbar-nav .nav-link,
  .dropdown-item {
    padding: 0.75rem 1rem;   /* ~44px tall - comfortable thumb target */
    font-size: 1rem;         /* 16px */
  }

  /* Dropdowns open inline instead of floating over the page */
  .navbar-nav .dropdown-menu {
    border: 0;
    box-shadow: none;
    padding-left: 1rem;
  }
}

.navbar-toggler { border-color: rgba(0,0,0,.15); }
.navbar-toggler:focus-visible { outline: 3px solid var(--et-blue); outline-offset: 2px; }


/* ============================================================================
   SECTION 6 - FOOTER
   ============================================================================ */

/* Section names in the site map. These need to look clearly different from
   the links beneath them, otherwise the four columns read as one long list of
   thirty links rather than four groups.

   They are plain links rather than headings on purpose. Headings here would
   appear in every page's outline whether the page wanted them or not. The
   grouping is communicated by the labelled <nav> in the HTML instead. */
.footer-section {
  display: block;
  margin-bottom: 0.75rem;
  font-family: rucksack, sans-serif;
  font-weight: 700;
  font-size: 0.8125rem;      /* 13px */
  text-transform: none;
  letter-spacing: 0.04em;
  line-height: 1.3;
  color: var(--et-ink);
}
.footer-section:hover,
.footer-section:focus-visible {
  color: var(--et-green-dark);
  text-decoration: underline;
}

/* Child links. Left-aligned, mixed case, lighter than the section name.
   The old version centred everything, which meant six links of different
   lengths under a two-line heading with nothing lining up. */
.footer-sitemap {
  text-align: left;
}
.footer-sitemap .nav-link {
  font-family: rucksack, sans-serif;
  font-weight: 500;
  font-size: 0.75rem;        /* 12px */
  text-transform: none;
  letter-spacing: 0.03em;
  color: var(--et-blue);
  padding-top: 0.15rem;
  padding-bottom: 0.15rem;
}
.footer-sitemap .nav-link:hover,
.footer-sitemap .nav-link:focus-visible {
  color: var(--et-blue-dark);
  text-decoration: underline;
}

/* Legal lines at the bottom */
.footer-legal a {
  color: var(--et-blue);
}
.footer-legal a:hover,
.footer-legal a:focus-visible {
  color: var(--et-blue-dark);
  text-decoration: underline;
}

.footer-logos img { display: inline-block; }


/* ============================================================================
   SECTION 7 - PAGE CONTENT HELPERS
   ============================================================================
   Styles for things being built now. Nothing here breaks anything if unused.
   ============================================================================ */

/* HOMEPAGE INTRO BLOCK
   Sits above the six cards. Markup:

     <hgroup class="page-intro text-center">
       <h1>Virtual Field Trips for Geoscience Education</h1>
       <p class="site-tagline">Helping our species navigate the promise
          and peril of the Anthropocene</p>
     </hgroup>

   The tagline is a paragraph, not a heading, because a heading promises
   content beneath it and this has none. <hgroup> marks it as a subtitle
   belonging to the h1.

   Size and outline level are independent - the tagline can be set larger
   than the h1 if that is the look you want. Adjust freely below. */
.page-intro {
  padding: 2.5rem 1rem 1.5rem;
}
.page-intro h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}
.site-tagline {
  font-size: 1.125rem !important;   /* overrides the global p rule */
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--et-green);
  margin-bottom: 0;
}

@media (max-width: 575.98px) {
  .page-intro { padding: 1.5rem 1rem 1rem; }
  .page-intro h1 { font-size: 1.25rem; }
  .site-tagline { font-size: 1rem !important; }
}

/* HOMEPAGE CARDS
   Card headings are <h2> - the page's <h1> is the intro block above them.
   If the h2 renders larger than you want, change it here rather than using a
   lower heading level. */
.card-title {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.card-title a {
  color: var(--et-ink);
  text-decoration: none;
}
.card-title a:hover,
.card-title a:focus-visible {
  color: var(--et-green);
  text-decoration: underline;
}

/* Keeps card images at a consistent 2:1 ratio (800x400) so the six cards
   line up even if one image is a slightly different size. */
.card img {
  aspect-ratio: 2 / 1;
  object-fit: cover;
  width: 100%;
}


/* ----------------------------------------------------------------------------
   WHOLE CARD CLICKABLE

   The image and the heading both act as one link to the section.

   HOW TO USE IT - add ONE class to the heading's link:

     <div class="card">
       <img src="/images/example.jpg" alt="Description of the picture">
       <div class="card-body">
         <h2 class="card-title">
           <a href="/lab/index.html" class="stretched-link">Section Name</a>
         </h2>
         <p>Blurb text.</p>
       </div>
     </div>

   The image stays a plain <img> with its own alt text. Do NOT wrap it in its
   own <a> as well. Bootstrap's .stretched-link invisibly expands the heading
   link to cover the whole card, which means:

     - a mouse user can click anywhere on the card
     - a screen reader hears ONE link, announced once, with the section name

   Wrapping the image in a second link would make a screen reader announce
   the same destination twice in a row, which is tedious to listen to.

   ONE SIDE EFFECT: text inside the card becomes hard to select with the
   mouse, because the invisible link sits on top of it. That is the accepted
   trade-off for whole-card clicking. If it ever becomes a problem, remove
   the .stretched-link class and the heading alone stays clickable.
   ---------------------------------------------------------------------------- */

/* Bootstrap's .card already sets position: relative, which .stretched-link
   needs to anchor itself to. This is here as a safety net in case the card
   markup ever changes. */
.card {
  position: relative;
}

/* Hover anywhere on the card lights up the heading, so it is obvious the
   whole thing is clickable. */
.card:hover .card-title a {
  color: var(--et-green);
  text-decoration: underline;
}

/* Optional: a subtle lift on hover. Automatically disabled for anyone who has
   asked their system for reduced motion - see Section 3. Delete these four
   lines if you would rather the cards stay flat. */
.card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.08);
}

/* KEYBOARD FOCUS ON CARDS

   With .stretched-link the link is technically just the heading text, so a
   keyboard user would get a focus ring around a few words floating in the
   middle of a big clickable card. That is confusing.

   :focus-within puts the focus ring around the whole card instead, matching
   what is actually clickable.

   The rule below is the ONE place in this file where an outline is removed,
   and only because it is being moved somewhere more useful, not deleted. The
   focus indicator is still clearly visible. Do not copy this pattern
   elsewhere. */
.card:focus-within {
  outline: 3px solid var(--et-blue);
  outline-offset: 2px;
}
.card .card-title a.stretched-link:focus-visible {
  outline: none;   /* moved to .card:focus-within above - still visible */
}


/* LEGAL PAGES - disclaimer, accessibility, privacy
   Narrower measure so long paragraphs stay readable. */
.legal-page {
  max-width: 48rem;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
}
.legal-page h2 {
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}
.legal-page p {
  font-size: 0.9375rem;      /* 15px - larger than the global 75% */
  line-height: 1.6;
}


/* EMBEDS - gigapans, virtual tours, videos
   Every <iframe> needs a title attribute in the HTML describing what it
   contains. Screen readers announce it, and without it the frame is just
   "frame". */
.embed-frame {
  width: 100%;
  border: 0;
  aspect-ratio: 16 / 9;
}

/* Used under an embed to hold its written description and controls.
   WCAG 2.2 requires anything operated by dragging to also work by clicking,
   so panoramas and 360 tours need visible buttons, not just drag-to-pan. */
.embed-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.embed-controls button {
  min-height: 44px;
  min-width: 44px;
}


/* ----------------------------------------------------------------------------
   SECTION LANDING PAGES - intro block and subsection cards

   Used on /models/index.html and, as they get built, the other four section
   landing pages. The pattern is: an h1 with a tagline under it, an
   introduction with a picture beside it, then a row of cards linking to the
   subsections.
   ---------------------------------------------------------------------------- */

/* Paragraph text beside the intro image. The global <p> rule in Section 2
   sets 75%, which is about 12px, too small for an introduction someone is
   meant to read. This matches the legal pages at 15px.

   These two numbers also decide whether the text lines up with the picture
   next to it. At the widest layout the column is 588px, so an 800x400 image
   renders 294px tall and three paragraphs of about 130 words render 288px.
   Changing the size or line height here will break that match. */
.section-intro p {
  font-size: 0.9375rem;
  line-height: 1.6;
}
.section-intro p:last-child {
  margin-bottom: 0;
}

/* THE SUBSECTION CARDS
   These carry an icon rather than a photograph, so they get a little more
   padding and a slightly smaller heading than the home page cards. They
   still inherit the border, hover lift and focus ring from the .card rules
   further up, so nothing about keyboard focus needs repeating here. */
.subsection-card .card-title {
  font-size: 1.0625rem;
  margin-bottom: 0.5rem;
}
.subsection-card .card-text {
  font-size: 0.8125rem;
  margin-bottom: 0;
}

/* THE ICONS
   Pasted into the page as inline SVG rather than loaded with <img>, which
   is the only way the colour below reaches them.

   The SVG elements carry no width or height of their own, so these two
   lines are what size them. Their fill is set to currentColor, so the
   colour below is what they take, and changing --et-green in Section 1
   changes all five at once.

   48px, not 40. At 36 the hourglass badge on the Deep Time globe and the
   fold creases on the map start closing up. 48 is where every icon in the
   set still reads. Going smaller costs legibility before it saves space. */
.subsection-icon {
  width: 3rem;             /* 48px */
  height: 3rem;
  color: var(--et-green);
  margin-bottom: 0.75rem;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* Icon deepens along with the heading when the card is hovered or focused.
   :focus-within is what covers keyboard users. They never trigger :hover,
   so without it a card would give them no feedback at all. */
.subsection-card:hover .subsection-icon,
.subsection-card:focus-within .subsection-icon {
  color: var(--et-green-dark);
}

@media (max-width: 575.98px) {
  .subsection-icon { width: 2.75rem; height: 2.75rem; }
}
