/*
 * style.css — Reflection Simulator
 * Breezeway Labs — https://breezewaylabs.com
 *
 * Copyright (c) 2015–2026 Keith Warren
 * MIT License — https://opensource.org/licenses/MIT
 */

/*
 * TABLE OF CONTENTS
 * ══════════════════════════════════════════
 *  1. Google Font import
 *  2. CSS custom properties (design tokens)
 *  3. Global reset
 *  4. Body / page shell
 *  5. .app — full-height flex container
 *  6. .topbar — header bar (title + controls)
 *     6a. Breadcrumb nav
 *     6b. Title & subtitle
 *     6c. .help — collapsible instructions panel
 *  7. .stage — canvas wrapper
 *  8. #sim — the simulation canvas
 *  9. Responsive overrides (≤720 px)
 * ══════════════════════════════════════════
 */

/* ══════════════════════════════════════════
   1. GOOGLE FONT IMPORT
   Space Grotesk is used for the UI text and
   for the protractor degree labels drawn on
   the canvas in app.js.
   ══════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600&display=swap');

/* ══════════════════════════════════════════
   2. CSS CUSTOM PROPERTIES (DESIGN TOKENS)
   Define the two colours used throughout the
   simulation shell. The periwinkle background
   matches the canvas fill in drawBackground().
   ══════════════════════════════════════════ */
:root {
  --bg: #9ca0c6;   /* periwinkle — matches canvas background colour in app.js */
  --text: #1b1b1f; /* near-black for readable body text */
}

/* ══════════════════════════════════════════
   3. GLOBAL RESET
   border-box sizing keeps padding/border
   inside declared widths — avoids surprise
   overflow on the canvas wrapper.
   ══════════════════════════════════════════ */
* {
  box-sizing: border-box;
}

/* ══════════════════════════════════════════
   4. BODY / PAGE SHELL
   Space Grotesk is the display font; fallbacks
   are system geometric sans-serifs.
   ══════════════════════════════════════════ */
body {
  margin: 0;
  font-family: "Space Grotesk", "Gill Sans", "Trebuchet MS", sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ══════════════════════════════════════════
   5. .app — FULL-HEIGHT FLEX CONTAINER
   Stretches to fill the viewport so the canvas
   stage can flex-grow and use all available
   vertical space.
   ══════════════════════════════════════════ */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ══════════════════════════════════════════
   6. .topbar — HEADER BAR
   Horizontal strip at the top of the page that
   holds the breadcrumb nav, title, subtitle,
   and the collapsible help panel.
   flex-wrap lets items reflow onto two lines
   on narrow viewports.
   ══════════════════════════════════════════ */
.topbar {
  padding: 14px 20px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
}

/* ── 6a. BREADCRUMB NAV ────────────────────
   Shows the path: ← Physics Lab / Reflection Simulator / Simulation
   Uses flex with a small gap between crumbs.
   The .sep spans are purely decorative dividers.
   ──────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  width: 100%; /* own row in the flex topbar so title sits below */
  flex-shrink: 0;
}

.breadcrumb a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-weight: 600;
  transition: color 120ms;
}

.breadcrumb a:hover {
  color: #ffffff;
  text-decoration: underline;
}

/* Separator "/" between breadcrumb segments */
.breadcrumb .sep {
  color: rgba(255, 255, 255, 0.4);
  user-select: none;
}

/* The final (current) segment — not a link, dimmer */
.breadcrumb .current {
  color: rgba(255, 255, 255, 0.55);
}

/* ── 6b. TITLE & SUBTITLE ──────────────────
   Title is the bold simulation name.
   Sub is the short usage hint shown beside it.
   ──────────────────────────────────────────── */
.title {
  font-weight: 600;
  font-size: 1.1rem;
}

.sub {
  font-size: 0.9rem;
  opacity: 0.8; /* slightly muted so it does not compete with the title */
}

/* ── 6c. .help — COLLAPSIBLE INSTRUCTIONS ──
   A <details>/<summary> element that reveals
   step-by-step instructions without JavaScript.
   margin-left: auto pushes it to the far right
   of the topbar flex row.
   ──────────────────────────────────────────── */
.help {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.3);
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  font-size: 0.9rem;
}

.help summary {
  cursor: pointer;
  font-weight: 600;
}

/* When the details element is open, raise the background opacity
   so the instruction text is easier to read. */
.help[open] {
  background: rgba(255, 255, 255, 0.85);
}

.help ul {
  margin: 8px 0 0 18px;
  padding: 0;
}

/* ══════════════════════════════════════════
   7. .stage — CANVAS WRAPPER
   flex: 1 lets the stage grow to fill all
   remaining vertical space below the topbar.
   The ::before pseudo-element adds a subtle
   rounded border frame around the canvas area
   as a decorative inset outline.
   ══════════════════════════════════════════ */
.stage {
  flex: 1;
  padding: 12px 20px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative; /* needed for the ::before absolute inset frame */
}

/* Decorative inset frame — rendered behind the canvas */
.stage::before {
  content: "";
  position: absolute;
  inset: 76px 20px 24px; /* top offset clears the topbar; sides match stage padding */
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  pointer-events: none; /* must not capture mouse events meant for the canvas */
}

/* ══════════════════════════════════════════
   8. #sim — THE SIMULATION CANVAS
   Width is 100% of the .stage so it scales
   with the viewport. max-height: 75vh prevents
   the canvas from being taller than the screen.
   app.js listens to window resize and calls
   resizeCanvas() to update the canvas buffer
   dimensions and device pixel ratio scaling.
   ══════════════════════════════════════════ */
#sim {
  width: 100%;
  height: auto;
  display: block;
  background: var(--bg); /* fallback colour before first draw() call */
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(20, 20, 40, 0.25);
  border: 3px solid rgba(255, 255, 255, 0.35);
  max-height: 75vh;
}

/* ══════════════════════════════════════════
   9. RESPONSIVE OVERRIDES (≤720 px)
   On mobile the topbar padding shrinks, the
   title font reduces, and the help panel
   expands to full width so it does not collide
   with the title text.
   ══════════════════════════════════════════ */
@media (max-width: 720px) {
  .topbar {
    padding: 12px 14px 8px;
  }

  .title {
    font-size: 1rem;
  }

  .sub {
    font-size: 0.82rem;
  }

  /* On mobile the help panel takes the full row width */
  .help {
    width: 100%;
    margin-left: 0;
  }

  .stage {
    padding: 10px 12px 18px;
  }

  #sim {
    border-radius: 10px;
  }
}
