/*
 * Calculus Cases — shared stylesheet for the activity generators of the book
 * "Calculus Casebook". Every activity page uses the same structure:
 *
 *   <section class="cc-case" data-lang="es|en">
 *     <section class="cc-workspace">          form (left) + summary/preview (right)
 *       <form class="cc-panel">…  .cc-form-grid, .cc-actions, .cc-status
 *       <aside class="cc-panel">… .cc-summary, .cc-preview
 *     <section class="cc-panel cc-documents"> tabs + file rows
 *       .cc-tabs > .cc-tab-button[data-cc-tab-target] … a.cc-tab-button.cc-complete
 *       .cc-tab-panel > .cc-file-list > .cc-file-row(.cc-primary)
 *
 * Colour tokens are the popcorn-box palette, adopted as the standard.
 */
.cc-case {
  --cc-ink: #202a3d;
  --cc-muted: #5d6570;
  --cc-line: #d9d5c8;
  --cc-paper: #f7f2e5;
  --cc-panel: #fffdf8;
  --cc-blue: #1385ae;
  --cc-blue-dark: #0b607f;
  --cc-orange: #e77924;
  --cc-orange-dark: #bc5517;
  --cc-red: #a43d35;
  --cc-yellow: #f3b632;
  --cc-field: #adb5bd;
  color-scheme: light;
  margin: 1.5rem 0 2rem;
  padding: 24px;
  border: 1px solid var(--cc-line);
  border-radius: 10px;
  background: var(--cc-paper);
  color: var(--cc-ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
.cc-case * { box-sizing: border-box; }
.cc-case h2, .cc-case h3 { margin-top: 0; color: var(--cc-ink); }
.cc-case h2 { font-size: 1.3rem; }
.cc-case h3 { font-size: 1.02rem; }
.cc-case p { color: var(--cc-muted); }
.cc-case .cc-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); gap: 22px; align-items: start; }
.cc-case .cc-panel { padding: 20px; border: 1px solid var(--cc-line); border-radius: 9px; background: var(--cc-panel); }
.cc-case .cc-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.cc-case .cc-full { grid-column: 1 / -1; }
.cc-case fieldset { grid-column: 1 / -1; margin: 4px 0 0; padding: 14px 14px 12px; border: 1px solid var(--cc-line); border-radius: 8px; }
.cc-case legend { padding: 0 6px; font-weight: 750; color: var(--cc-ink); }
.cc-case label { display: grid; gap: 6px; color: var(--cc-ink); font-weight: 700; }
.cc-case input, .cc-case select { width: 100%; min-height: 43px; padding: 8px 10px; border: 1px solid var(--cc-field); border-radius: 6px; background: #fff; color: var(--cc-ink); font: inherit; }
.cc-case input:focus, .cc-case select:focus { outline: 2px solid var(--cc-blue); outline-offset: 1px; }
.cc-case input[aria-invalid="true"] { border-color: var(--cc-red); }
.cc-case input:disabled { background: #eef0f1; color: #555; }
.cc-case .cc-mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .06em; text-transform: uppercase; }
.cc-case .cc-help { margin: -4px 0 0; font-size: .86rem; color: var(--cc-muted); font-weight: 400; }
.cc-case .cc-inline { display: flex; gap: 8px; align-items: stretch; }
.cc-case .cc-inline input { flex: 1; }
.cc-case .cc-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.cc-case button { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 14px; border: 1px solid transparent; border-radius: 6px; font: inherit; font-weight: 750; text-decoration: none; cursor: pointer; }
.cc-case button[type="submit"], .cc-case .cc-primary-button { background: var(--cc-orange); color: #fff; }
.cc-case button[type="submit"]:hover, .cc-case .cc-primary-button:hover { background: var(--cc-orange-dark); color: #fff; }
.cc-case button.cc-secondary { border-color: #aeb7be; background: #fff; color: var(--cc-ink); }
.cc-case button.cc-secondary:hover { border-color: var(--cc-blue); color: var(--cc-blue-dark); }
.cc-case button:disabled { cursor: wait; opacity: .65; }
.cc-case .cc-status { min-height: 24px; margin-top: 12px; color: var(--cc-blue-dark); font-weight: 700; }
.cc-case .cc-error { color: #a32d22; }
.cc-case .cc-note { margin: 10px 0 0; padding: 8px 10px; border-left: 4px solid var(--cc-yellow); background: #fff8e6; color: var(--cc-ink); font-size: .88rem; font-weight: 400; }
.cc-case .cc-note.cc-warn { border-left-color: var(--cc-red); background: #fbecea; }
.cc-case .cc-summary { display: grid; gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; }
.cc-case .cc-summary li { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 8px; border-bottom: 1px solid #ece8de; }
.cc-case .cc-summary strong { text-align: right; color: var(--cc-blue-dark); }
.cc-case .cc-preview { width: 100%; min-height: 120px; padding: 10px; border: 1px solid var(--cc-line); border-radius: 7px; background: #fff; }
.cc-case .cc-preview svg, .cc-case .cc-preview img, .cc-case .cc-preview canvas { display: block; width: 100%; height: auto; }
.cc-case .cc-preview figure { margin: 0 0 10px; }
.cc-case .cc-preview figure:last-child { margin-bottom: 0; }
.cc-case .cc-preview figcaption { margin-top: 4px; font-size: .8rem; color: var(--cc-muted); }
.cc-case .cc-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: .82rem; color: var(--cc-muted); }
.cc-case .cc-documents { margin-top: 22px; }
.cc-case .cc-download-note { margin-bottom: 16px; }
.cc-case .cc-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--cc-line); }
.cc-case .cc-tab-button { display: inline-flex; align-items: center; min-height: 42px; padding: 9px 14px; border: 1px solid #aeb7be; border-radius: 6px; background: #fff; color: var(--cc-ink); font: inherit; font-weight: 750; text-decoration: none; cursor: pointer; }
.cc-case .cc-tab-button[aria-selected="true"] { border-color: var(--cc-blue-dark); background: var(--cc-blue-dark); color: #fff; }
.cc-case .cc-tab-button.cc-complete { border-color: var(--cc-orange); color: #9e4815; }
.cc-case .cc-tab-button.cc-complete:hover { background: #fff5e9; color: #7d3510; }
.cc-case .cc-tab-panel[hidden] { display: none; }
.cc-case .cc-file-list { display: grid; gap: 10px; }
.cc-case .cc-file-group { margin: 6px 0 -2px; font-size: .8rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; color: var(--cc-muted); }
.cc-case .cc-file-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px; padding: 8px 10px 8px 14px; border: 1px solid #aeb7be; border-radius: 7px; background: #fff; color: var(--cc-ink); font-weight: 750; }
.cc-case .cc-file-row:hover { border-color: var(--cc-blue); color: var(--cc-blue-dark); }
.cc-case .cc-file-row.cc-primary { border-color: var(--cc-red); background: var(--cc-red); color: #fff; }
.cc-case .cc-file-title { min-width: 0; overflow-wrap: anywhere; }
.cc-case .cc-file-title small { display: block; font-weight: 400; font-size: .8rem; opacity: .85; }
.cc-case .cc-file-actions { display: flex; flex: none; gap: 8px; }
.cc-case .cc-file-icon { display: inline-flex; width: 36px; height: 36px; align-items: center; justify-content: center; border: 1px solid currentColor; border-radius: 6px; background: rgba(255,255,255,.85); color: inherit; text-decoration: none; }
.cc-case .cc-file-icon svg { width: 18px; height: 18px; stroke: currentColor; }
.cc-case .cc-file-icon:hover, .cc-case .cc-file-icon:focus { background: #fff; color: var(--cc-blue-dark); }
.cc-case .cc-file-row.cc-primary .cc-file-icon { border-color: rgba(255,255,255,.8); background: rgba(255,255,255,.14); color: #fff; }
.cc-case .cc-file-row.cc-primary .cc-file-icon:hover, .cc-case .cc-file-row.cc-primary .cc-file-icon:focus { background: #fff; color: #7f2d28; }
.cc-case .cc-hidden { display: none !important; }
.cc-case .cc-noscript { padding: 12px; border-left: 4px solid var(--cc-orange); background: #fff; }

/* Page-level elements shared by every activity post */
.cc-figure { margin: 1.4rem 0; }
.cc-figure img { display: block; width: 100%; height: auto; border-radius: 8px; }
.cc-figure figcaption { margin-top: .4rem; font-size: .85rem; color: #5d6570; }
.cc-gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 1.2rem 0; }
.cc-gallery figure { margin: 0; }
.cc-gallery img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 6px; }
.cc-gallery figcaption { margin-top: .25rem; font-size: .78rem; color: #5d6570; line-height: 1.3; }
.cc-disclaimer { font-size: .88rem; color: #5d6570; }

@media (max-width: 820px) {
  .cc-case { padding: 15px; }
  .cc-case .cc-workspace, .cc-case .cc-form-grid { grid-template-columns: 1fr; }
  .cc-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.cc-app-actions { margin: .75rem 0 .5rem; }
