/* ==========================================================================
   Kalkuli additions (loaded after style.css)
   Article layout, bylines, Learn hub, and fixes for the tool pages.
   ========================================================================== */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--win-accent);
  color: #fff;
  padding: 0.5rem 0.9rem;
  z-index: 2000;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

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

/* Page titles: every page now has a real, visible h1 */
.page-title-box { margin-bottom: 1.25rem; }
.page-title-box h1 {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}
.page-title-box .subtitle { font-size: 0.975rem; max-width: 70ch; }

.byline {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-tertiary);
}
.byline a { color: var(--text-secondary); font-weight: 600; text-decoration: none; }
.byline a:hover { color: var(--win-accent); text-decoration: underline; }

/* Footer headings were h4s styled in style.css; they are h2s now */
.footer-heading {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  margin-bottom: 0.85rem;
}
.footer-desc a { color: var(--win-accent); }
.footer-desc + .footer-desc { margin-top: -0.25rem; }

.modal-header h2 { font-size: 1rem; font-weight: 600; }
.history-header h2 { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.history-item { width: 100%; font: inherit; border: 1px solid var(--win-border); }
.tool-notes { max-width: 860px; margin-left: auto; margin-right: auto; }
.modal-desc a { color: var(--win-accent); }

/* ---------- Long-form article prose ---------- */
.prose {
  background: var(--win-card-bg);
  border: 1px solid var(--win-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 2rem 2.25rem;
  font-size: 1rem;
  line-height: 1.7;
  color: #2b2b2b;
}
.prose + .prose { margin-top: 1.5rem; }
.prose > * + * { margin-top: 1rem; }
.prose h2 {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  margin-top: 2.25rem;
  padding-top: 0.25rem;
}
.prose h2:first-child { margin-top: 0; }
.prose h3 {
  font-size: 1.08rem;
  font-weight: 650;
  color: var(--text-primary);
  margin-top: 1.6rem;
}
.prose p, .prose li { max-width: 72ch; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: 0.35rem; }
.prose code { font-size: 0.86em; }
.prose strong { color: var(--text-primary); }
.prose a { text-decoration: underline; text-underline-offset: 2px; }

.prose .eq {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  background: var(--win-card-secondary);
  border: 1px solid var(--win-border);
  border-left: 3px solid var(--win-accent);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  overflow-x: auto;
  white-space: pre;
  color: #12355b;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  display: block;
  overflow-x: auto;
}
.prose th, .prose td {
  text-align: left;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--win-border);
  white-space: nowrap;
}
.prose th { background: var(--win-card-secondary); font-weight: 600; color: var(--text-primary); }
.prose td.num, .prose th.num { text-align: right; font-variant-numeric: tabular-nums; }

.note, .worked, .pitfall {
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  border: 1px solid var(--win-border);
}
.note { background: var(--win-accent-light); border-color: rgba(0, 103, 192, 0.2); }
.worked { background: #f6faf7; border-color: rgba(22, 121, 76, 0.22); }
.pitfall { background: #fff8f1; border-color: rgba(176, 96, 0, 0.25); }
.note > :first-child, .worked > :first-child, .pitfall > :first-child { margin-top: 0; }
.note > * + *, .worked > * + *, .pitfall > * + * { margin-top: 0.6rem; }
.box-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.worked .box-label { color: #16794c; }
.pitfall .box-label { color: #a35a00; }

kbd {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: #fff;
  border: 1px solid var(--win-border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
}

.toc {
  background: var(--win-card-secondary);
  border: 1px solid var(--win-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
}
.toc ol { margin-top: 0.4rem; }

.try-it {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  background: var(--win-card-secondary);
  border: 1px dashed var(--win-border-strong);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.1rem;
}
.try-it p { margin: 0; flex: 1 1 260px; }
.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--win-accent);
  color: #fff !important;
  text-decoration: none !important;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
}
.btn-link:hover { background: var(--win-accent-hover); }

.related {
  margin-top: 1.5rem;
  background: var(--win-card-bg);
  border: 1px solid var(--win-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}
.related h2 { font-size: 1rem; font-weight: 700; margin-bottom: 0.6rem; }
.related ul { list-style: none; display: grid; gap: 0.4rem; }
.related a { font-weight: 500; }

/* ---------- Learn hub ---------- */
.learn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}
.learn-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: var(--win-card-bg);
  border: 1px solid var(--win-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 1.15rem 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.learn-card:hover { border-color: var(--win-accent); transform: translateY(-1px); }
.learn-card h3 { font-size: 1rem; font-weight: 650; color: var(--text-primary); line-height: 1.35; }
.learn-card p { font-size: 0.86rem; color: var(--text-secondary); line-height: 1.5; }
.learn-card .tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--win-accent);
}
.learn-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 2rem 0 0.85rem;
}
.learn-section-title:first-of-type { margin-top: 0.5rem; }

/* ---------- Tool page extras ---------- */
.tool-notes { margin-top: 1.5rem; }

.matrix-size-toggle { display: flex; gap: 0.4rem; justify-content: center; margin-bottom: 0.5rem; }
.matrix-cell-input.hidden-cell { display: none; }
.matrix-input-table td.hidden-cell { display: none; }

.solver-warning {
  background: #fff8f1;
  border: 1px solid rgba(176, 96, 0, 0.25);
  color: #7a4300;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.solver-warning[hidden] { display: none; }

.solution-step-math { white-space: pre-wrap; word-break: break-word; }

.calc-primary-display.is-error { color: #c53030; font-size: 1.5rem; }

.unit-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.unit-table th, .unit-table td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--win-border); text-align: left; }
.unit-table td:last-child { font-family: var(--font-mono); text-align: right; }

/* About page portrait-free author card */
.author-card {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
.author-initials {
  flex: 0 0 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--win-accent);
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.changelog { list-style: none; padding-left: 0 !important; }
.changelog li { border-left: 2px solid var(--win-border-strong); padding-left: 0.9rem; }
.changelog time { font-weight: 600; color: var(--text-primary); }

@media (max-width: 680px) {
  .prose { padding: 1.35rem 1.15rem; font-size: 0.97rem; }
  .page-title-box h1 { font-size: 1.45rem; }
  .win-nav { overflow-x: auto; flex-wrap: nowrap; }
}

/* ---------- Small helpers used by the tool pages ---------- */
.steps-heading { font-size: 1rem; font-weight: 600; color: var(--text-primary); margin-top: 1.25rem; }
.unit-select-wrap { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); }
.solver-input-field.compact { width: auto; padding: 0.3rem 0.5rem; font-size: 0.85rem; }
.field-group-label { margin-bottom: 0.6rem; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.05em; color: var(--text-tertiary); text-transform: uppercase; }
.card-divider { margin: 1.5rem 0 1.1rem; border: none; border-top: 1px solid var(--win-border); }
.solver-card-title.small { font-size: 1rem; margin-bottom: 0.75rem; }
.comb-result { margin-top: 0.9rem; font-weight: 700; color: var(--win-accent); font-variant-numeric: tabular-nums; }
.small-note { margin-top: 0.4rem; font-size: 0.78rem; color: var(--text-tertiary); line-height: 1.45; }
.solver-input-wrap.spaced { margin-bottom: 1.25rem; }
.table-scroll { overflow-x: auto; }
.matrix-wrap { text-align: center; margin: 1.25rem 0; }
.solver-actions.centred { justify-content: center; }
.sidebar-heading { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.4rem; }
.sidebar-heading.small { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); }
.sidebar-text { font-size: 0.85rem; color: var(--text-secondary); }
.sidebar-list { font-size: 0.85rem; color: var(--text-secondary); padding-left: 1.1rem; margin-top: 0.3rem; line-height: 1.55; }
.formula-group h2 {
  font-size: 1.15rem; font-weight: 600; color: var(--text-primary);
  margin-bottom: 1rem; border-bottom: 1px solid var(--win-border); padding-bottom: 0.5rem;
}
.formula-card a { font-size: 0.8rem; }
.legal-card.prose { padding: 1.75rem 2rem; }
.legal-card.prose h2 { font-size: 1.15rem; margin-top: 1.75rem; }
.legal-card.prose h2:first-child { margin-top: 0; }
.faq-question { font-size: 1.05rem; }
.solver-card-header { gap: 0.75rem; flex-wrap: wrap; }
@media (max-width: 680px) {
  .win-nav .nav-link { padding: 0.35rem 0.5rem; }
  .win-nav { scrollbar-width: none; }
}
