/* ============================================================
   COLOR VARIABLES – Shared palette
   ============================================================ */
:root {
  --color-bg: #FFFFFF;
  --color-text: #000000;
  --color-purple: #4B116F;
  --color-gold: #FFCC00; /* Optional higher-contrast alt: #E2B100 */
  --color-card-bg: #FFFFFF;
  --color-card-accent: #EEE5F5;
  --color-highlight-bg: #FFFB9F;
  --color-link: #6600BB;
  --color-note: #555555;
}

/* ============================================================
   RESET & BASE LAYOUT
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
  background: var(--color-bg);
  color: var(--color-text);
  font: 16px Verdana, sans-serif;
  line-height: 1.6;
  margin: 0;
}

.main {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px 40px;
}

/* ============================================================
   ACCESSIBILITY – Skip Link + Focus
   ============================================================ */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  padding: 8px 12px;
  background: var(--color-purple);
  color: #fff;
  text-decoration: none;
  z-index: 1000;
}
.skip-link:focus {
  left: 8px;
  top: 8px;
}

/* ============================================================
   LINKS
   ============================================================ */
a {
  color: var(--color-link);
  text-decoration: underline;
}
a:hover {
  text-decoration: underline;
  text-underline-offset: 2px; /* clearer affordance */
}
a:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 2px;
}

/* Optional tiny indicators (opt-in via class in HTML) */
a.external::after { content: "↗"; font-size: 0.9em; margin-left: 0.15em; }
a.pdf::after      { content: " (PDF)"; font-size: 0.95em; }

/* ============================================================
   TYPOGRAPHY unique to topic pages
   ============================================================ */
/* Harmonize heading weight with front page
.topic h1, h2 {
  font-size: 28px;
  font-weight: 400;
  color: #000;
  margin: 28px 0 18px;
  line-height: 1.3;
}
*/

/* Rounded purple ### on topic pages */
.topic h2 {
  background: #4B116F;
  color: #FFF;
  font-size: 22px;
  padding: 10px 16px;
  margin: 24px 0 16px;
  font-weight: 300;
  line-height: 1.4;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}


/*
.topic h3 {
  border-bottom: 2px solid #4B116F;
  padding-bottom: 4px;
  margin: 20px 0 12px;
  font-weight: 500;
}
*/

/* Minimal styled h3 now that h2 uses the purple box */
.topic h3 {
  border-bottom: 2px solid #4B116F;  /* subtle purple underline */
  padding-bottom: 4px;
  margin: 22px 0 12px;
  font-weight: 500;
  font-size: 20px;
  color: #000;
  line-height: 1.3;
}


/* Body text */
.topic p { margin: 10px 0 14px; }
.topic ul, ol { padding-left: 24px; margin: 10px 0 14px; }

/* ============================================================
   HEADER HERO
   ============================================================ */
.header-hero {
  background: #4B116F; /* Design View will see this */
  background: var(--color-purple);
  color: #fff;
  padding: 30px 0;
}

/* Fluid titles for better scaling on all devices */
.page-title   { font-size: clamp(1.6rem, 2.5vw + 1rem, 2.2rem); font-weight: 400; margin: 0 0 10px; }
.page-subtitle{ font-size: clamp(1.1rem, 1.5vw + 0.8rem, 1.6rem); font-weight: 300; margin: 0; }

/* ============================================================
   WEEK SECTIONS
   ============================================================ */
.week { margin-top: 40px; }

.week-title {
  background: var(--color-purple);
  color: var(--color-gold);
  padding: 12px 15px;
  font-size: 1.3rem;
  margin: 0 0 15px;
  border-radius: 6px;
  font-weight: 600; /* contrast/readability nudge */
  /* If you prefer darker gold instead, change --color-gold to #E2B100 */
}

/* ============================================================
   CARD LAYOUT
   ============================================================ */
.card {
  display: grid;
  /* Was: 180px 1fr — use flexible minmax for medium screens */
  grid-template-columns: minmax(160px, 240px) 1fr;
  border: 1px solid #000;
  margin-bottom: 12px;
  background: var(--color-card-bg);
  border-radius: 6px;
}

.card-category {
  background: var(--color-card-accent);
  padding: 12px;
  font-weight: bold;
  border-right: 1px solid #000;
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
}

.card.preflection .card-category {
  background: #185FA5;
  color: #E6F1FB;
  border-right-color: #0C447C;
}

.card-content { padding: 12px; }

/* Highlighted card */
.card.highlight { background: var(--color-highlight-bg); }

/* Roomier lists inside cards */
.card-content ul,
.card-content ol { 
  margin: 8px 0 12px;
  padding-left: 22px;
}

/* ============================================================
   TABLE STYLES
   ============================================================ */
.week-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}
.week-table th {
  background: var(--color-purple);
  color: var(--color-gold);
  padding: 8px;
  text-align: left;
}
.week-table td { border: 1px solid #000; padding: 8px; }

/* ============================================================
   SCROLLABLE TABLE WRAPPER
   ============================================================ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: 480px; }

/* ============================================================
   UTILITY
   ============================================================ */
.resource-list { list-style: disc; padding-left: 20px; }
.note { color: var(--color-note); font-size: 0.9rem; }

img, svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 14px 0;
}

/* ============================================================
   RESPONSIVE BEHAVIOR
   ============================================================ */
/* Medium breakpoint: gently compress card's left column for small tablets */
@media (max-width: 820px) {
  .card { grid-template-columns: minmax(140px, 200px) 1fr; }
}

/* Stack cards earlier (phones & small tablets) */
@media (max-width: 700px) {
  .card {
    grid-template-columns: 1fr;
  }
  .card-category {
    border-right: none;
    border-bottom: 1px solid #000;
    border-bottom-left-radius: 0;
    border-top-right-radius: 6px;
  }
}

/* Phone refinements */
@media (max-width: 600px) {
  body { font-size: 15px; }
  h1, h2 { font-size: 24px; }
  h3 { font-size: 20px; padding: 8px 14px; }
  .main { padding: 0 12px 32px; }
  .container { flex-direction: column; }
}

/* ============================================================
   MEDIA (inline media containers)
   ============================================================ */
.container {
  display: flex;
  align-items: center;
  gap: 20px;
}
.container img { flex: 0 0 auto; }
.container .text-content { flex: 1; }

/* ============================================================
   CALLOUT BOXES (harmonized aesthetic)
   ============================================================ */
.callout {
  border: 3px solid #FFCC00;
  background: #FFF8D6;
  padding: 14px 16px;
  margin: 20px 0;
  border-radius: 6px;
}

.callout.EYL {
  border-color: #4B116F;
  background: #F7F1FA;
}

/* ============================================================
   PREFER REDUCED MOTION (future-friendly)
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   PRINT (ink-friendly handouts)
   ============================================================ */
@media print {
  .header-hero { background: #fff; color: #000; }
  a { color: #000; text-decoration: underline; }
  .card, .callout, .callout.EYL { border-color: #000; box-shadow: none; }
  .main { padding: 0; }
}

/* ============================================================
   BREADCRUMB Utility
============================================================ */

.breadcrumb {
  font-size: 0.9rem;
  margin-bottom: 8px;
  opacity: 0.9;
}

.breadcrumb a {
  color: #fff;
  text-decoration: underline;
}

.breadcrumb a:hover {
  text-underline-offset: 2px;
}

.breadcrumb .current {
  color: var(--color-gold);
  font-weight: 600;
}

.breadcrumb span {
  margin: 0 4px;
}

/* ============================================================
   FCCS STYLE PATCH – Modernization & Technical Formatting
   ============================================================ */

/* 1. Improved Reading Rhythm */
.topic {
  max-width: 72ch; /* Optimized for reading speed and focus */
}

.topic p {
  margin-bottom: 1.5em; /* Adds more 'breathable' white space */
}

/* 2. Technical Data & Code */
/* Use for binary strings, hex values, or logic */
code {
  font-family: "Courier New", Courier, monospace;
  background-color: #f0f0f0;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.95em;
  color: #c41e3a; /* Subtle contrast for technical terms */
}

/* 3. "Big Idea" Blockquote */
blockquote {
  margin: 24px 0;
  padding: 16px 24px;
  border-left: 5px solid var(--color-gold);
  background: #fffdf5;
  font-style: italic;
  border-radius: 0 6px 6px 0;
}

blockquote p {
  margin: 0;
  font-weight: 500;
  color: #333;
}

/* 4. Softer, Interactive Cards */
.card {
  border: 1px solid #ddd; /* Softer than pure black */
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(75, 17, 111, 0.15); /* Subtle purple glow */
  border-color: var(--color-purple);
}

.card-category {
  border-right: 1px solid #ddd;
}

/* 5. Enhanced Breadcrumb Current State */
.breadcrumb .current {
  background-color: rgba(255, 204, 0, 0.2); /* Soft gold highlight */
  padding: 2px 6px;
  border-radius: 4px;
}


/* =======================================
   Place-value tables (decimal & binary)
   Used in Topic 1B, Reading 2 and elsewhere
   ======================================= */

.pv-table {
  display: grid;
  margin: 1.25rem 0;
  border-collapse: collapse;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.pv-table .cell {
  text-align: center;
  padding: 0.4rem 0.5rem;
  border: 1px solid #ddd;
  font-size: 0.95rem;
}

/* Color coding for header / place values / digits */
.pv-table .header {
  background-color: #e7ddff; /* soft purple */
  font-weight: 600;
}

.pv-table .place {
  background-color: #d8e9ff; /* soft blue */
  font-weight: 500;
}

.pv-table .digit {
  background-color: #ffe9c7; /* light orange */
  font-weight: 600;
  font-size: 1.05rem;
}

/* Column layouts */
.pv-4col {
  grid-template-columns: repeat(4, minmax(2rem, 3rem));
}

.pv-8col {
  grid-template-columns: repeat(8, minmax(2rem, 3rem));
}

/* Simple math / code emphasis lines */
.math-line {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 600;
}

.code-display {
  text-align: center;
  font-family: monospace;
  font-size: 1.25rem;
}

/* Slightly smaller centered emphasis, e.g., sums */
.math-line-small {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
}

/* Responsive tweaks */
@media (max-width: 600px) {
  .pv-4col {
    grid-template-columns: repeat(4, minmax(2.2rem, 3rem));
  }

  .pv-8col {
    grid-template-columns: repeat(8, minmax(2.2rem, 3rem));
  }

  .pv-table .cell {
    font-size: 1rem;
    padding: 0.55rem 0.6rem;
  }

  .code-display {
    font-size: 1.2rem;
  }

  .math-line,
  .math-line-small {
    font-size: 1.05rem;
  }
}

/* =======================================
   ASCII lookup table on pv-table grid
   12 columns: (Dec, Hex, Char) × 4 groups
   ======================================= */
.ascii-12col {
  display: grid;
  grid-template-columns: repeat(12, minmax(2.2rem, 1fr));
  margin: 1.25rem 0;
}

/* Highlight the Char column cells */
.char-col {
  background-color: #fff8d6;  /* soft gold tint */
  font-weight: 600;
}

/* Stronger highlight for Char column headers */
.pv-table .header.char-col {
  background-color: #ffe9a3;  /* slightly deeper gold */
}


.center-img {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================================
   READING NAV — Bottom navigation bar on reading pages
   Links to next reading (mid-series) or CFU section (final reading)
   ============================================================ */
.reading-nav {
  background: var(--color-purple);
  margin-top: 48px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.reading-nav .main {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-top: 14px;
  padding-bottom: 14px;
}

.reading-nav a {
  color: #fff;
  text-decoration: underline;
  font-size: 0.95rem;
  font-weight: 600;
}

.reading-nav a:hover {
  color: var(--color-gold);
  text-underline-offset: 3px;
}