/* Engineering Graphics Essentials — Companion Website
   Second Edition · Static site for any host
   Accessibility: WCAG 2.2 AA targets (WAVE-aligned) */

:root {
  --navy: #0b1f3a;
  --steel: #1a3658; /* darkened for AA contrast on sand/white */
  --accent: #a8431a; /* darkened for white text AA */
  --accent-hover: #8a3615;
  --sand: #f4f1ea;
  --paper: #ffffff;
  --ink: #1a1a1a;
  --muted: #3d4654; /* AA on sand (~7:1+) */
  --line: #c4bdb2;
  --ok: #0f5c38;
  --ok-bg: #e6f5ec;
  --err: #9b1c1c;
  --err-bg: #fdecec;
  --warn: #8a4508;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(11, 31, 58, 0.08);
  --max: 1100px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Consolas", "Courier New", monospace;
  --focus: #ffbf47;
}

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

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--sand);
  line-height: 1.55;
  min-height: 100vh;
}

/* Skip link — WAVE / WCAG 2.4.1 */
.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -100px;
  z-index: 1000;
  background: var(--focus);
  color: #000;
  padding: 0.65rem 1rem;
  font-weight: 700;
  border-radius: 0 0 6px 6px;
  text-decoration: underline;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid #000;
  outline-offset: 2px;
}

/* Visible focus for all interactive elements */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

a {
  color: var(--steel);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent);
}

/* Nav/buttons intentionally no underline (clear role + focus) */
.nav a,
.brand,
.btn,
.card a.btn {
  text-decoration: none;
}

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

/* Layout */
.site-header {
  background: linear-gradient(135deg, var(--navy), var(--steel));
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  color: #fff;
}

.brand:hover {
  color: #fff;
  text-decoration: underline;
}

.brand strong {
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.brand span {
  font-size: 0.78rem;
  color: #e8eef6; /* solid color, not opacity — better contrast */
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.nav a {
  color: #fff;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  font-size: 0.88rem;
  border: 1px solid transparent;
}

.nav a:hover,
.nav a[aria-current="page"] {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

.menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.7);
  color: #fff;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.site-footer {
  background: var(--navy);
  color: #e8eef6;
  padding: 1.5rem 1.25rem;
  text-align: center;
  font-size: 0.9rem;
}

.site-footer a {
  color: #ffd7c2;
  text-decoration: underline;
}

.site-footer .footer-note {
  color: #c5d0de; /* AA on navy */
  font-size: 0.88rem;
}

/* Hero */
.hero {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--accent);
  margin-bottom: 1.5rem;
}

.hero h1 {
  margin: 0 0 0.5rem;
  color: var(--navy);
  font-size: clamp(1.5rem, 3vw, 2rem);
  line-height: 1.25;
}

.hero p {
  margin: 0.4rem 0;
  color: var(--muted);
  max-width: 60ch;
}

.badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
}

/* Cards grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

@media (prefers-reduced-motion: no-preference) {
  .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(11, 31, 58, 0.12);
  }
}

.card h2,
.card h3 {
  margin: 0;
  color: var(--navy);
  font-size: 1.05rem;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  flex: 1;
}

.card .meta {
  font-size: 0.8rem;
  color: var(--steel);
  font-weight: 600;
}

.card a.btn,
.btn {
  display: inline-block;
  align-self: flex-start;
  background: var(--steel);
  color: #fff !important;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  margin-top: 0.5rem;
  font-family: inherit;
}

.card a.btn:hover,
.btn:hover {
  background: var(--accent);
}

.btn-accent {
  background: var(--accent) !important;
}

.btn-outline {
  background: var(--paper) !important;
  color: var(--steel) !important;
  border: 2px solid var(--steel);
}

.btn-outline:hover {
  background: var(--steel) !important;
  color: #fff !important;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Panels */
.panel {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  margin-bottom: 1.25rem;
}

.panel h2 {
  margin-top: 0;
  color: var(--navy);
  border-bottom: 2px solid var(--line);
  padding-bottom: 0.45rem;
}

.panel h3 {
  color: var(--steel);
  margin-bottom: 0.4rem;
}

/* Progress */
.progress-wrap {
  margin-top: 1.25rem;
}

.progress-bar {
  height: 12px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.5rem 0 0.25rem;
}

.progress-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--steel), var(--accent));
  width: 0%;
  transition: width 0.35s ease;
}

.progress-label {
  font-size: 0.9rem;
  color: var(--muted);
}

/* Checklist */
.checklist {
  list-style: none;
  padding: 0;
  margin: 0;
}

.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--line);
}

.checklist li:last-child {
  border-bottom: none;
}

.checklist input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.15rem;
  accent-color: var(--ok);
  cursor: pointer;
  flex-shrink: 0;
}

.checklist label {
  cursor: pointer;
  flex: 1;
}

.checklist input:checked + label {
  text-decoration: line-through;
  color: var(--muted);
}

/* Quiz */
.quiz-q {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  background: #fafafa;
}

.quiz-q fieldset {
  border: none;
  margin: 0;
  padding: 0;
}

.quiz-q legend {
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.75rem;
  padding: 0;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.quiz-options label {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--paper);
}

.quiz-options label:hover {
  border-color: var(--line);
}

.quiz-options label.correct {
  background: var(--ok-bg);
  border-color: var(--ok);
}

.quiz-options label.incorrect {
  background: var(--err-bg);
  border-color: var(--err);
}

.quiz-options label.correct::before {
  content: "✓ ";
  font-weight: 700;
  color: var(--ok);
}

.quiz-options label.incorrect::before {
  content: "✗ ";
  font-weight: 700;
  color: var(--err);
}

.quiz-feedback {
  margin-top: 0.6rem;
  font-size: 0.9rem;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  display: none;
  border-left: 4px solid transparent;
}

.quiz-feedback.show {
  display: block;
}

.quiz-feedback.ok {
  background: var(--ok-bg);
  color: var(--ok);
  border-left-color: var(--ok);
}

.quiz-feedback.bad {
  background: var(--err-bg);
  color: var(--err);
  border-left-color: var(--err);
}

.score-box {
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  display: none;
  margin-bottom: 1rem;
}

.score-box.show {
  display: block;
}

/* Command reference */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
  align-items: center;
}

.toolbar input[type="search"],
.toolbar select,
.toolbar input[type="text"] {
  font: inherit;
  padding: 0.55rem 0.75rem;
  border: 2px solid var(--line);
  border-radius: 6px;
  min-width: 200px;
  background: var(--paper);
  color: var(--ink);
}

.toolbar input:focus,
.toolbar select:focus {
  border-color: var(--steel);
}

.command-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.command-table th,
.command-table td {
  text-align: left;
  padding: 0.65rem 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.command-table th {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 36px;
  z-index: 2;
  font-weight: 700;
}

/* Command-name cells in each row: styled like normal cells */
.command-table tbody th {
  background: transparent;
  color: inherit;
  position: static;
  font-weight: 600;
}

.command-table tr:hover td {
  background: #f8f5f0;
}

.command-table caption {
  text-align: left;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.5rem;
  caption-side: top;
}

.command-table code {
  font-family: var(--mono);
  background: #eef2f7;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  color: var(--steel);
  font-weight: 600;
}

.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #e8eef6;
  color: var(--steel);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

/* Line type visual cards */
.line-demo {
  display: grid;
  gap: 0.75rem;
}

.line-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem 1rem;
}

.line-item strong {
  color: var(--navy);
}

.line-svg {
  width: 100%;
  height: 28px;
  margin: 0.45rem 0;
}

/* GD&T symbols */
.gdt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.gdt-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem;
  background: #fff;
  text-align: center;
}

.gdt-symbol {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--navy);
  font-family: var(--mono);
  margin-bottom: 0.35rem;
  min-height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gdt-card h3 {
  margin: 0.25rem 0;
  color: var(--steel);
  font-size: 0.95rem;
}

.gdt-card p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

/* Chapter page */
.chapter-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.takeaways {
  background: #fff8f2;
  border-left: 4px solid var(--accent);
  padding: 0.9rem 1rem;
  border-radius: 0 8px 8px 0;
  margin: 1rem 0;
}

.takeaways h2,
.takeaways h3 {
  margin-top: 0;
  color: var(--accent);
}

/* Tabs */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.tabs button {
  font: inherit;
  border: 2px solid var(--line);
  background: var(--paper);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--steel);
}

.tabs button[aria-selected="true"],
.tabs button.active {
  background: var(--steel);
  color: #fff;
  border-color: var(--steel);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-panel[hidden] {
  display: none !important;
}

/* Flashcards */
.flashcard {
  background: var(--paper);
  border: 2px solid var(--steel);
  border-radius: var(--radius);
  min-height: 160px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  user-select: none;
  box-shadow: var(--shadow);
  margin-bottom: 0.75rem;
  width: 100%;
  font: inherit;
}

.flashcard .front {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
}

.flashcard .back {
  display: none;
  color: var(--ink);
}

.flashcard.flipped .front {
  display: none;
}

.flashcard.flipped .back {
  display: block;
}

.flashcard-controls {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Utility */
.muted {
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
}

@media (max-width: 720px) {
  .menu-toggle {
    display: block;
  }

  .nav {
    display: none;
    width: 100%;
    flex-direction: column;
  }

  .nav.open {
    display: flex;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .command-table th {
    top: 0;
  }
}

/* Print */
@media print {
  .site-header,
  .site-footer,
  .menu-toggle,
  .btn-row,
  .skip-link {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .panel,
  .card {
    box-shadow: none;
    border: 1px solid #ccc;
  }

  a {
    text-decoration: underline;
  }
}
