/* ==========================================================================
   Phydelta Limited — brand.css (web kit, issue #13)
   Base styles and framework-free components for any Phydelta website.
   Every colour, font, type size and spacing value comes from the design tokens.
   The few component sizes of its own (bar width, button and header heights,
   card minimum, icon size) are listed in the README under "Decisions to confirm".
   No shadows, no gradients, radius 0 (2px for tags). Night mode comes from
   the tokens: system preference, or <html data-theme="dark|light">.
   Imports the tokens from ../tokens/tokens.css.
   ========================================================================== */
@import url("../tokens/tokens.css");

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
strong, b { font-weight: 600; }
p + p { margin-top: var(--s-2); }

a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
    transition: text-decoration-color var(--dur) var(--ease); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: var(--focus); outline-offset: 3px; }

.ph-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.ph-skip-link {
  position: absolute; left: var(--s-2); top: -100px; z-index: 100;
  background: var(--text); color: var(--bg); padding: var(--s-1) var(--s-2);
  font-family: var(--font-mono); font-size: var(--fs-label); text-transform: uppercase; text-decoration: none;
}
.ph-skip-link:focus { top: var(--s-2); }

/* Theme-dependent images: logo files are swapped, never recoloured.
   Ink logo in light mode, Paper logo in night mode. */
.ph-only-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ph-only-light { display: none; }
  :root:not([data-theme="light"]) .ph-only-dark { display: block; }
}
:root[data-theme="dark"] .ph-only-light { display: none; }
:root[data-theme="dark"] .ph-only-dark { display: block; }

/* ---------- layout: container, 12-column grid, sections ---------- */
.ph-container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.ph-grid { display: grid; grid-template-columns: repeat(var(--columns), minmax(0, 1fr)); gap: var(--s-3) var(--gutter); }
.ph-grid > * { grid-column: 1 / -1; }
@media (min-width: 768px) {
  .ph-col-3 { grid-column: span 3; }
  .ph-col-4 { grid-column: span 4; }
  .ph-col-5 { grid-column: span 5; }
  .ph-col-6 { grid-column: span 6; }
  .ph-col-7 { grid-column: span 7; }
  .ph-col-8 { grid-column: span 8; }
}
.ph-section { padding-block: var(--section-pad); border-top: var(--rule-w) solid var(--rule); }
.ph-section:first-of-type { border-top: 0; }
.ph-rule { border: 0; border-top: var(--rule-w) solid var(--rule); margin: var(--s-4) 0; }

/* ---------- type ---------- */
.ph-h1, .ph-h2 {
  font-family: var(--font-display); font-weight: 400; text-transform: uppercase;
}
.ph-h1 { font-size: min(var(--fs-h1), 96px); line-height: var(--lh-display); } /* 96px = brand H1 */
.ph-h2 { font-size: var(--fs-h2); line-height: 1; }
.ph-h3 { font-family: var(--font-text); font-size: var(--fs-h3); font-weight: 600; line-height: 1.2; }
.ph-lead { font-size: var(--fs-lead); line-height: 1.4; max-width: 34em; }
.ph-small { font-size: var(--fs-small); }
.ph-muted { color: var(--text-muted); }
.ph-measure { max-width: 68ch; }

/* Spec label: Courier New, uppercase. "01 / PROFILE" */
.ph-label {
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 400;
  letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--text-muted);
}
/* Section head: label above an Impact title with a hairline under it */
.ph-section-head { margin-bottom: var(--s-6); }
.ph-section-head .ph-label { display: block; margin-bottom: var(--s-2); }
.ph-section-head .ph-h2 { padding-bottom: var(--s-3); border-bottom: var(--rule-w) solid var(--rule); }

/* Signal bar: 4px, under ONE heading per view (P2). */
.ph-signal-bar { display: block; width: 80px; height: var(--signal-bar); background: var(--accent); margin-block: var(--s-4); border: 0; }

/* ---------- △ list: every marker in Signal ---------- */
.ph-delta-list { list-style: none; padding: 0; }
.ph-delta-list > li { position: relative; padding-left: 1.6em; }
.ph-delta-list > li + li { margin-top: var(--s-1); }
.ph-delta-list > li::before {
  content: "\25B3"; /* △ U+25B3, never a copy of the logo triangle */
  position: absolute; left: 0; top: 0;
  color: var(--accent); font-family: var(--font-text); font-size: 0.85em; line-height: 1.75;
}

/* ---------- links ---------- */
.ph-link-mono {
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: var(--ls-label); text-transform: uppercase;
}
.ph-link-icon { display: inline-flex; align-items: center; gap: var(--s-1); }
.ph-link-icon svg { width: 18px; height: 18px; flex: none; }

/* ---------- buttons: square; primary = Ink fill (Paper at night); never red ---------- */
.ph-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-1);
  min-height: 48px; padding: 0 var(--s-3);
  font-family: var(--font-text); font-weight: 600; font-size: var(--fs-small);
  letter-spacing: 0.02em; line-height: 1.2; text-decoration: none;
  border: 2px solid var(--text); border-radius: var(--radius);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
  cursor: pointer;
}
.ph-btn svg { width: 18px; height: 18px; }
.ph-btn--primary { background: var(--text); color: var(--bg); }
.ph-btn--primary:hover { background: transparent; color: var(--text); }
.ph-btn--secondary { background: transparent; color: var(--text); }
.ph-btn--secondary:hover { background: var(--text); color: var(--bg); }
.ph-btn--small { min-height: 40px; padding: 0 var(--s-2); font-size: var(--fs-label); }
.ph-btn-row { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* ---------- tags ---------- */
.ph-tags { display: flex; flex-wrap: wrap; gap: var(--s-1); list-style: none; padding: 0; }
.ph-tag {
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: var(--ls-label); text-transform: uppercase; line-height: 1.4;
  border: var(--rule-w) solid var(--rule); border-radius: 2px; padding: 4px 10px;
}

/* ---------- card ---------- */
.ph-card { background: var(--surface); border: var(--rule-w) solid var(--rule); padding: var(--s-4); overflow-wrap: anywhere; }
.ph-card > .ph-label { display: block; margin-bottom: var(--s-2); }
.ph-card > .ph-h3 { margin-bottom: var(--s-2); }
.ph-card > :last-child { margin-bottom: 0; }
.ph-cards { display: grid; gap: var(--s-3); }
@media (min-width: 768px) { .ph-cards { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--gutter); } }

/* ---------- table ---------- */
.ph-table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
.ph-table caption { text-align: left; margin-bottom: var(--s-2); }
.ph-table th, .ph-table td { text-align: left; vertical-align: top; padding: var(--s-2) var(--s-3) var(--s-2) 0; border-bottom: var(--rule-w) solid var(--rule); }
.ph-table thead th {
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 400;
  letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--text-muted);
  border-bottom: 2px solid var(--text);
}
.ph-table tbody th { font-weight: 600; }
.ph-table .ph-num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
/* The value label of the one highlighted datum (P2, docs/09_DATAVIZ.md): the label only */
.ph-table .ph-highlight { color: var(--accent); }
.ph-table-wrap { overflow-x: auto; }

/* ---------- navigation: the active item has its text in Signal (P2) ---------- */
.ph-nav ul { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); list-style: none; padding: 0; }
.ph-nav a {
  display: inline-block; padding-block: var(--s-1);
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: var(--ls-label); text-transform: uppercase;
  text-decoration: none; color: var(--text); white-space: nowrap;
}
.ph-nav a:hover { text-decoration: underline; }
.ph-nav a[aria-current] { color: var(--accent); }

/* Language switch: EN / ES */
.ph-lang { font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: var(--ls-label); text-transform: uppercase; white-space: nowrap; }
.ph-lang a { color: var(--text-muted); text-decoration: none; }
.ph-lang a:hover { color: var(--text); text-decoration: underline; }
.ph-lang [aria-current] { color: var(--text); }

/* Theme toggle (needs theme.js): uses the line icon "theme" */
.ph-theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0; background: none; border: 0; color: var(--text); cursor: pointer;
}
.ph-theme-toggle svg { width: 22px; height: 22px; }

/* ---------- header ---------- */
.ph-header { background: var(--bg); border-bottom: var(--rule-w) solid var(--rule); }
.ph-header--sticky { position: sticky; top: 0; z-index: 50; }
.ph-header__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-3); min-height: 72px; padding-block: var(--s-1); }
.ph-header__logo { display: block; flex: none; width: 180px; } /* 180px = minimum width of the horizontal logo */
.ph-header__logo img { width: 180px; height: auto; }
.ph-header__tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }

/* ---------- footer: legal line always says Phydelta Limited ---------- */
.ph-footer { border-top: var(--rule-w) solid var(--rule); padding-block: var(--s-4); }
.ph-footer__inner { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); align-items: center; justify-content: space-between; }
.ph-footer__legal { display: flex; align-items: center; gap: var(--s-2); font-family: var(--font-mono); font-size: var(--fs-label); color: var(--text-muted); }
.ph-footer__legal img { width: 20px; height: 20px; }
.ph-footer__links { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-3); list-style: none; padding: 0; }
.ph-footer__links a { font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: var(--ls-label); text-transform: uppercase; }
.ph-footer__links svg { width: 20px; height: 20px; }

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
