/* ==========================================================================
   Trinity Tech Labs — shared design system
   iOS/Apple HIG-inspired. Single source of truth for every page on the site.

   Loaded as <link rel="stylesheet" href="/assets/site.css"> from all pages,
   including nested ones (/everstead/blog/post.html) — the leading slash makes
   the path absolute, so depth doesn't matter.

   Sections:
     1. Tokens (light + dark)
     2. Base elements
     3. Layout
     4. Typography scale
     5. Buttons
     6. Navigation
     7. Cards & grouped lists
     8. Hero
     9. Prose (article body)
    10. Footer
    11. Motion
   ========================================================================== */

/* ---------------------------------------------------------------- 1. TOKENS */

:root {
  /* Apple system greys — these are the real iOS values */
  --bg:            #F2F2F7;  /* systemGroupedBackground */
  --bg-elevated:   #FFFFFF;  /* secondarySystemGroupedBackground */
  --surface:       #FFFFFF;
  --surface-2:     #F2F2F7;

  --label:         #000000;
  --label-2:       rgba(60, 60, 67, 0.60);  /* secondaryLabel */
  --label-3:       rgba(60, 60, 67, 0.30);  /* tertiaryLabel */
  --separator:     rgba(60, 60, 67, 0.29);
  --separator-opaque: #C6C6C8;

  --tint:          #007AFF;  /* systemBlue */
  --tint-hover:    #0063CC;
  --tint-wash:     rgba(0, 122, 255, 0.10);

  --green:         #34C759;
  --orange:        #FF9500;
  --red:           #FF3B30;

  /* Translucent nav — the frosted-glass effect */
  --nav-bg:        rgba(249, 249, 249, 0.82);
  --nav-border:    rgba(0, 0, 0, 0.10);

  /* Radii — iOS uses generous, consistent corners */
  --r-sm:  10px;
  --r-md:  14px;
  --r-lg:  18px;
  --r-xl:  22px;
  --r-pill: 980px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 1px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.04);

  --max:      1080px;
  --max-text: 720px;   /* comfortable measure for articles */
  --gutter:   22px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #000000;
    --bg-elevated:   #1C1C1E;
    --surface:       #1C1C1E;
    --surface-2:     #2C2C2E;

    --label:         #FFFFFF;
    --label-2:       rgba(235, 235, 245, 0.60);
    --label-3:       rgba(235, 235, 245, 0.30);
    --separator:     rgba(84, 84, 88, 0.65);
    --separator-opaque: #38383A;

    --tint:          #0A84FF;  /* iOS brightens blue in dark mode */
    --tint-hover:    #409CFF;
    --tint-wash:     rgba(10, 132, 255, 0.16);

    --green:         #30D158;
    --orange:        #FF9F0A;
    --red:           #FF453A;

    --nav-bg:        rgba(28, 28, 30, 0.80);
    --nav-border:    rgba(255, 255, 255, 0.10);

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.30);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.40);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.55);
  }
}

/* ------------------------------------------------------------- 2. BASE */

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font-family: var(--font);
  font-size: 17px;          /* iOS body size */
  line-height: 1.53;
  letter-spacing: -0.01em;  /* SF is designed with slight negative tracking */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a { color: var(--tint); text-decoration: none; }
a:hover { color: var(--tint-hover); }

:focus-visible {
  outline: 3px solid var(--tint);
  outline-offset: 3px;
  border-radius: 4px;
}

hr {
  border: 0;
  height: 1px;
  background: var(--separator);
  margin: 40px 0;
}

::selection { background: var(--tint-wash); }

/* ----------------------------------------------------------- 3. LAYOUT */

.wrap {
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.wrap-text { max-width: var(--max-text); }

section { padding: 72px 0; }
section.tight { padding: 48px 0; }

.stack > * + * { margin-top: 16px; }

/* iOS grouped-list section header: small, uppercase, muted */
.group-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--label-2);
  margin: 0 0 12px;
}

/* ------------------------------------------------------- 4. TYPOGRAPHY */

h1, h2, h3, h4 {
  color: var(--label);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.022em;  /* SF Pro Display tracking */
  margin: 0 0 0.5em;
  text-wrap: balance;
}

h1 { font-size: clamp(34px, 5.2vw, 56px); }
h2 { font-size: clamp(26px, 3.4vw, 38px); }
h3 { font-size: clamp(20px, 2.2vw, 24px); letter-spacing: -0.018em; }
h4 { font-size: 18px; letter-spacing: -0.014em; }

p { margin: 0 0 1em; color: var(--label-2); }

.lede {
  font-size: clamp(18px, 2vw, 21px);
  line-height: 1.45;
  color: var(--label-2);
  letter-spacing: -0.014em;
  text-wrap: pretty;
}

.eyebrow {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tint);
  margin-bottom: 14px;
}

.footnote {
  font-size: 13px;
  color: var(--label-2);
  letter-spacing: 0;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* ---------------------------------------------------------- 5. BUTTONS */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 17px;
  font-weight: 590;          /* SF's semibold */
  letter-spacing: -0.01em;
  line-height: 1;
  padding: 15px 26px;
  border: 0;
  border-radius: var(--r-pill);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .18s ease, color .18s ease,
              transform .12s ease, opacity .18s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--tint); color: #fff; }
.btn-primary:hover { background: var(--tint-hover); color: #fff; }

/* iOS "tinted" button — wash background, tint-colored label */
.btn-tinted { background: var(--tint-wash); color: var(--tint); }
.btn-tinted:hover { background: var(--tint); color: #fff; }

.btn-plain { background: transparent; color: var(--tint); padding-inline: 8px; }
.btn-plain:hover { color: var(--tint-hover); }

.btn-sm { font-size: 15px; padding: 10px 18px; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.btn-row.center { justify-content: center; }

/* --------------------------------------------------------- 6. NAVIGATION */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--nav-border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 52px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--label);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.018em;
}
.brand:hover { color: var(--label); }
.brand-mark { width: 24px; height: 24px; flex: none; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 26px;
}
.nav-links a {
  font-size: 15px;
  font-weight: 400;
  color: var(--label-2);
  letter-spacing: -0.01em;
}
.nav-links a:hover { color: var(--label); }
.nav-links a.current { color: var(--label); font-weight: 500; }

@media (max-width: 640px) {
  .nav-links { gap: 18px; }
  .nav-links a.hide-sm { display: none; }
}

/* --------------------------------------------------- 7. CARDS & LISTS */

.card {
  background: var(--bg-elevated);
  border-radius: var(--r-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.feature h3 { margin-bottom: 8px; font-size: 19px; }
.feature p  { margin: 0; font-size: 15px; line-height: 1.5; }

.feature-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  background: var(--tint-wash);
  color: var(--tint);
  display: grid;
  place-items: center;
  margin-bottom: 16px;
}
.feature-icon svg { width: 22px; height: 22px; }

/* iOS inset grouped list — rows inside one rounded container */
.list {
  background: var(--bg-elevated);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  color: var(--label);
  border-bottom: 1px solid var(--separator);
  transition: background .15s ease;
}
.row:last-child { border-bottom: 0; }
a.row:hover { background: var(--surface-2); color: var(--label); }

.row-body { flex: 1; min-width: 0; }
.row-body h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 3px;
  letter-spacing: -0.016em;
}
.row-body p { margin: 0; font-size: 15px; line-height: 1.45; }

/* The iOS disclosure chevron */
.chevron {
  flex: none;
  width: 9px;
  height: 15px;
  color: var(--label-3);
}

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  background: var(--tint-wash);
  color: var(--tint);
  white-space: nowrap;
}
.badge-green  { background: rgba(52,199,89,0.14);  color: var(--green); }
.badge-orange { background: rgba(255,149,0,0.14);  color: var(--orange); }
.badge-muted  { background: var(--surface-2);      color: var(--label-2); }

@media (prefers-color-scheme: dark) {
  .badge-green  { background: rgba(48,209,88,0.18); }
  .badge-orange { background: rgba(255,159,10,0.18); }
}

/* ------------------------------------------------------------- 8. HERO */

.hero {
  padding: clamp(56px, 9vw, 104px) 0 clamp(48px, 7vw, 88px);
  text-align: center;
}
.hero h1 { margin-bottom: 20px; }
.hero .lede { max-width: 40ch; margin-inline: auto; margin-bottom: 32px; }
.hero .btn-row { justify-content: center; }

.hero-left { text-align: left; }
.hero-left .lede { margin-inline: 0; }
.hero-left .btn-row { justify-content: flex-start; }

/* ------------------------------------------------------------ 9. PROSE */

.prose {
  font-size: 18px;
  line-height: 1.68;
  color: var(--label-2);
  letter-spacing: -0.011em;
}
.prose > * + * { margin-top: 1.15em; }
.prose h2 {
  font-size: clamp(23px, 2.6vw, 29px);
  margin-top: 1.9em;
  margin-bottom: 0.45em;
}
.prose h3 {
  font-size: clamp(19px, 2vw, 22px);
  margin-top: 1.6em;
  margin-bottom: 0.4em;
}
.prose p { margin-bottom: 0; }
.prose strong { color: var(--label); font-weight: 600; }
.prose a { text-decoration: underline; text-underline-offset: 3px; }

.prose ul, .prose ol { padding-left: 1.3em; margin-block: 1.15em; }
.prose li { margin-bottom: 0.55em; }
.prose li::marker { color: var(--label-3); }

.prose blockquote {
  margin: 1.7em 0;
  padding: 4px 0 4px 22px;
  border-left: 3px solid var(--tint);
  color: var(--label);
  font-size: 1.03em;
}

.prose img { border-radius: var(--r-md); margin-block: 1.7em; }

.prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--label);
}

/* Tables — wrapped in .table-scroll so narrow screens scroll the table,
   not the whole page. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-block: 1.7em;
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15.5px;
  margin: 0;
}
.prose th,
.prose td {
  text-align: left;
  padding: 13px 18px;
  border-bottom: 1px solid var(--separator);
  vertical-align: top;
}
.prose thead th {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--label-2);
  background: var(--surface-2);
  white-space: nowrap;
}
.prose tbody tr:last-child td { border-bottom: 0; }
.prose td:first-child { color: var(--label); font-weight: 500; }

/* Callout box for tips inside articles */
.callout {
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  padding: 20px 22px;
  margin-block: 1.7em;
  box-shadow: var(--shadow-sm);
  font-size: 16px;
}
.callout p:last-child { margin-bottom: 0; }
.callout strong { color: var(--label); }

/* Article header block */
.article-head { padding: 44px 0 8px; }
.article-head h1 {
  font-size: clamp(30px, 4.4vw, 44px);
  margin-bottom: 16px;
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--label-2);
  margin-bottom: 8px;
}
.article-meta .dot { color: var(--label-3); }

/* Back link with iOS-style leading chevron */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 15px;
  color: var(--tint);
  margin-bottom: 26px;
}
.back-link svg { width: 8px; height: 13px; }

/* ---------------------------------------------------------- 10. FOOTER */

.site-footer {
  border-top: 1px solid var(--separator);
  padding: 36px 0 48px;
  margin-top: 40px;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
}
.footer-links a {
  font-size: 14px;
  color: var(--label-2);
}
.footer-links a:hover { color: var(--tint); }
.footer-note { font-size: 13px; color: var(--label-3); }

/* ----------------------------------------------------------- 11. MOTION */

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .55s ease, transform .55s ease;
}
.reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
