/*
 * MobileClient-347 shared component stylesheet.
 * Consumes tokens.css exclusively — no hardcoded color values in this file.
 */

*,
*::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;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--accent-deep);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
}
a:hover {
  color: var(--accent);
}
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}

/* Skip-to-content link — hidden until focused (keyboard/screen-reader users only) */
.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  background: var(--ink);
  color: var(--paper);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  z-index: 100;
  font-family: var(--font-body);
  font-weight: 600;
}
.skip-link:focus {
  left: var(--space-4);
  top: var(--space-4);
}

/* Typography scale */
h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  color: var(--ink);
  margin: 0 0 var(--space-4);
  text-wrap: balance;
  line-height: 1.08;
}
h1 {
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  font-weight: 800;
  letter-spacing: -0.01em;
}
h2 {
  font-size: clamp(1.7rem, 3.4vw, 2.4rem);
  font-weight: 700;
}
h3 {
  font-size: 1.3rem;
  font-weight: 700;
}
h4 {
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
p {
  margin: 0 0 var(--space-4);
  max-width: 62ch;
}
.eyebrow {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-deep);
  display: inline-block;
  margin-bottom: var(--space-2);
}

/* Layout primitives */
.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}
.section {
  padding: var(--space-24) 0;
}
.section + .section {
  border-top: 1px solid var(--rule);
}
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: center;
}
.grid {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

/* Nav */
.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  max-width: 1080px;
  margin: 0 auto;
}
.site-nav .wordmark {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
}
.site-nav .wordmark img {
  height: 28px;
  width: auto;
}
.site-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  font-size: 0.92rem;
  font-weight: 600;
}
.site-nav a {
  color: var(--ink);
  text-decoration: none;
}
.site-nav a:hover {
  color: var(--accent);
}
.site-nav a[aria-current='page'] {
  color: var(--accent-deep);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 2px;
}
.nav-toggle {
  display: none;
  background: none;
  border: 1.5px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-body);
  font-weight: 700;
}
/* Research Papers dropdown — a labeled disclosure, not a hidden/obscured link (Explicit
   Preservation Constraint: the 7 algebra pages + tour stay one click away, clearly named). */
.nav-dropdown {
  position: relative;
}
.nav-dropdown-trigger {
  background: none;
  border: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}
.nav-dropdown-trigger:hover {
  color: var(--accent);
}
.nav-dropdown.is-current .nav-dropdown-trigger {
  color: var(--accent-deep);
}
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: var(--space-2);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated);
  padding: var(--space-2);
  min-width: 240px;
  z-index: 20;
}
.nav-dropdown-menu.is-open {
  display: flex;
  flex-direction: column;
}
.nav-dropdown-menu a {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  font-weight: 500;
}
.nav-dropdown-menu a:hover {
  background: var(--paper-deep);
}
.nav-dropdown-menu a[aria-current='page'] {
  color: var(--accent-deep);
  font-weight: 700;
  border-bottom: none;
}
/* Without JS the dropdown is still fully reachable — CSS-only hover/focus-within fallback */
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  display: flex;
  flex-direction: column;
}

.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;
}

@media (max-width: 720px) {
  .site-nav {
    flex-wrap: wrap;
  }
  .nav-toggle {
    display: inline-flex;
  }
  .site-nav ul,
  #nav-links {
    flex-basis: 100%;
    display: none;
    flex-direction: column;
    gap: var(--space-3);
    padding-top: var(--space-3);
    list-style: none;
    margin: 0;
    padding-left: 0;
  }
  .site-nav ul.is-open,
  #nav-links.is-open {
    display: flex;
  }
  .nav-dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    margin-top: var(--space-1);
    padding-left: var(--space-4);
  }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.98rem;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-sm);
  text-decoration: none;
  border: 2px solid transparent;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    background 0.12s ease;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn-primary {
  background: var(--accent);
  color: var(--paper);
}
.btn-primary:hover {
  background: var(--accent-deep);
  color: var(--paper);
}
.btn-secondary {
  background: transparent;
  border-color: var(--ink);
  color: var(--ink);
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
}

/* Blog post-list (Update Goblin / Audience Surrogate TOCs) — a pre-existing gap: these classes
   were used in the original site with zero CSS definition anywhere. Styled properly now. */
.post-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-6);
}
.post-link {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  background: var(--paper-deep);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--ink);
  transition: background 0.12s ease;
}
.post-link:hover {
  background: var(--accent-tint);
}
.post-link-date {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 9ch;
}
.post-link-title {
  flex: 1;
  font-weight: 700;
}
.post-link-arrow {
  flex-shrink: 0;
  color: var(--accent-deep);
}

/* Cards — accent-rule treatment on the top edge, not a uniform rounded-box everywhere */
.card {
  background: var(--paper-deep);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
}
.card.feature {
  border-top: var(--accent-rule-width) solid var(--accent);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.card.elevated {
  box-shadow: var(--shadow-elevated);
  border-radius: var(--radius-lg);
}

/* Hero */
.hero {
  padding: var(--space-24) 0 var(--space-16);
}
.hero .eyebrow {
  color: var(--accent-deep);
}
.hero p.lede {
  font-size: 1.2rem;
  color: var(--muted);
  max-width: 52ch;
}
.hero-art {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-elevated);
}
.hero-art img {
  width: 100%;
  height: auto;
  display: block;
}

/* Screenshot / illustration grid */
.showcase-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.showcase-grid figure {
  margin: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.showcase-grid img {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}
.showcase-grid figcaption {
  font-size: 0.82rem;
  color: var(--muted);
  padding: var(--space-2) var(--space-3);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: var(--space-12) 0;
  font-size: 0.88rem;
  color: var(--muted);
}
.site-footer a {
  color: var(--muted);
}
.site-footer a:hover {
  color: var(--accent-deep);
}
.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.footer-nav a {
  font-weight: 600;
}
.footer-contact {
  margin-bottom: var(--space-2);
}
.footer-contact a {
  color: var(--accent-deep);
}
.footer-copyright {
  margin-bottom: 0;
  font-size: 0.82rem;
}
.footer-patent {
  color: var(--muted);
  opacity: 0.75;
}

/* Utility page (legal/support) — narrower measure, no hero */
.doc {
  max-width: 72ch;
  margin: 0 auto;
  padding: var(--space-16) var(--space-6);
}
.doc h2 {
  margin-top: var(--space-12);
}

/* Workflows / Architecture reference pages (MobileClient-350) — neutral technical-reference
   tone, distinct from the Update Goblin's parchment/goblin styling on the SDLC Papers series.
   Wider measure than .doc since these pages carry diagrams, not just prose. */
.workflow-doc {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-16) var(--space-6);
}
.workflow-doc h2 {
  margin-top: var(--space-12);
}
.workflow-eyebrow {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
}
.workflow-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin: var(--space-8) 0;
}
.workflow-card {
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.workflow-card h3 {
  margin-top: 0;
  font-size: 1.05rem;
}
.workflow-card p {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 0;
}
/* Diagrams keep an always-light card behind them regardless of site theme — the rendered SVG
   itself is opaque white, so the card just frames it consistently rather than fighting dark mode. */
.diagram {
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  margin: var(--space-8) 0;
  text-align: center;
  overflow-x: auto;
}
.diagram img {
  margin: 0 auto;
}
.diagram-caption {
  margin-top: var(--space-3);
  font-size: 0.9rem;
  color: var(--muted);
  text-align: left;
}
.workflow-nav {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: var(--space-8);
  padding-top: var(--space-4);
  border-top: 1px solid var(--rule);
  font-size: 0.92em;
}
/* Lightweight revision tracking for Workflows pages (MobileClient-350, Papers/Workflows
   consistency pass) — a dated one-liner per edit, not the Papers' full revision-history table.
   Workflows pages are meant to stay leaner than the Papers; this is the proportionate version
   of the same "revisions are tracked, out loud" discipline. */
.workflow-revision {
  margin-top: var(--space-6);
  padding-top: var(--space-3);
  border-top: 1px dashed var(--rule);
  font-size: 0.85rem;
  color: var(--muted);
}
.workflow-revision p {
  margin: 0 0 var(--space-2) 0;
}
.workflow-revision p:last-child {
  margin-bottom: 0;
}
.workflow-revision strong {
  color: var(--ink);
}

/* Responsive */
@media (max-width: 600px) {
  .wrap {
    padding: 0 var(--space-4);
  }
  .section {
    padding: var(--space-16) 0;
  }
  .hero {
    padding: var(--space-16) 0 var(--space-8);
  }
  .workflow-doc {
    padding: var(--space-8) var(--space-4);
  }
}
