/* ============================================================
   SHARED STYLESHEET
   Every page links to this one file. That is the point of a
   design system: the tokens and components live in one place,
   and each page is just markup that reaches for them.
   ============================================================ */


/* ============================================================
   1. TOKENS
   ============================================================ */

:root {
  /* --- Color --- */
  --paper:        #FBF9F5;
  --surface:      #FFFFFF;
  --surface-sunk: #F4F1EA;

  --ink:          #1F1D1A;
  --ink-2:        #5C574E;
  --ink-3:        #8A8579;

  --accent:       #B4562C;
  --accent-hover: #94441F;
  --accent-soft:  #F3E6DF;

  --line:         #E6E0D6;
  --line-strong:  #D2CABB;

  /* --- Typography --- */
  --font-body:    ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: Georgia, "Iowan Old Style", "Times New Roman", serif;

  --size-caption: 0.8125rem;
  --size-small:   0.9375rem;
  --size-body:    1.0625rem;

  /* Headings scale FLUIDLY with the viewport via clamp(min, preferred, max).
     The middle value grows with vw, and clamp pins it between the two ends.
     A 42px h1 that looks confident on a laptop is overbearing on a phone;
     this shrinks it smoothly instead of snapping at a breakpoint. */
  --size-h3:      clamp(1.25rem, 1.15rem + 0.5vw, 1.375rem);
  --size-h2:      clamp(1.5rem,  1.25rem + 1.2vw, 1.875rem);
  --size-h1:      clamp(2rem,    1.5rem + 2.4vw, 2.625rem);

  --leading-tight: 1.2;
  --leading-body:  1.65;

  --weight-normal: 400;
  --weight-bold:   600;

  /* --- Spacing --- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1.25rem;
  --space-5: 2rem;
  --space-6: 3.25rem;

  /* --- Shape --- */
  --radius:      6px;
  --radius-lg:   14px;
  --radius-pill: 999px;
  --border:      1px solid var(--line);

  --avatar:    76px;
  --avatar-sm: 36px;

  /* --- Controls --- */
  --control-height: 42px;
  --fill-field:     var(--surface);

  /* --- Focus ---
     One ring definition, used everywhere. Consistency matters
     more here than anywhere: a keyboard user learns this shape
     once and then recognises it on every control. */
  --focus-ring: 2px solid var(--accent);

  /* --- Motion --- */
  --transition: 140ms ease;

  /* --- Measure ---
     Line length for long-form reading. 65 characters is the
     usual comfortable range; much wider and the eye loses its
     place returning to the next line. */
  --measure: 65ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:        #16150F;
    --surface:      #1F1D17;
    --surface-sunk: #14130E;

    --ink:          #F0EDE4;
    --ink-2:        #B3ADA0;
    --ink-3:        #837D71;

    --accent:       #E0855A;
    --accent-hover: #EFA37D;
    --accent-soft:  #3A2418;

    --line:         #322F26;
    --line-strong:  #494537;

    --fill-field:   #14130E;
  }
}


/* --- Reduced motion ---------------------------------------
   Some people get motion sickness from interface animation,
   and set a system preference to say so. Honouring it costs
   two lines: collapse every transition to almost nothing. */

@media (prefers-reduced-motion: reduce) {
  :root { --transition: 1ms linear; }
  * { animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
}


/* ============================================================
   2. BASE
   ============================================================ */

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: var(--space-6) var(--space-4);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--size-body);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
}

.page { max-width: 720px; margin: 0 auto; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: var(--weight-normal);
  line-height: var(--leading-tight);
  margin: 0;
}

h1 { font-size: var(--size-h1); }
h2 { font-size: var(--size-h2); }
h3 { font-size: var(--size-h3); }

p { margin: 0 0 var(--space-3); }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

.muted   { color: var(--ink-2); }
.caption { color: var(--ink-3); font-size: var(--size-caption); }

.rule { border: 0; border-top: var(--border); margin: var(--space-5) 0; }

img { max-width: 100%; height: auto; }   /* never overflow the column */


/* --- Focus ------------------------------------------------
   :focus-visible, not :focus. The difference matters: :focus
   fires on mouse clicks too, so buttons keep a ring after
   being clicked, which looks broken and leads people to
   remove focus styling altogether. :focus-visible fires only
   when the browser judges a ring is warranted — keyboard
   navigation, essentially. Never write `outline: none`
   without providing a replacement. */

:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius);
}


/* ============================================================
   3. COMPONENTS
   ============================================================ */

/* --- Avatar --- */

.avatar {
  display: block;
  width: var(--avatar);
  height: var(--avatar);
  object-fit: cover;
  background: var(--surface-sunk);
  flex-shrink: 0;
}

.avatar-circle  { border-radius: 50%; }
.avatar-rounded { border-radius: var(--radius-lg); }
.avatar-sm      { width: var(--avatar-sm); height: var(--avatar-sm); }

/* --- Site header --- */

.site-header { margin-bottom: var(--space-6); }

.identity {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.identity h1 { font-size: var(--size-h2); }
.identity p  { margin: 0; }

/* --- Nav: underline tabs. Reserved for TOP-LEVEL navigation. --- */

.tabs {
  display: flex;
  gap: var(--space-4);
  border-bottom: var(--border);
}

.tabs a {
  padding: var(--space-2) var(--space-1) var(--space-3);
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--ink-2);
  font-size: var(--size-small);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}

.tabs a:hover { color: var(--ink); }

.tabs a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* --- Pills. Reserved for FILTERING WITHIN a page.
       Keeping these two treatments in separate roles is what
       makes the layout communicate hierarchy on its own. --- */

.pills { display: flex; gap: var(--space-1); flex-wrap: wrap; }

.pills button,
.pills a {
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: var(--size-small);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.pills button:hover,
.pills a:hover { background: var(--surface-sunk); color: var(--ink); }

.pills [aria-pressed="true"],
.pills [aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

/* --- Card --- */

.card {
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
}

/* --- Button --- */

.btn {
  display: inline-block;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--size-small);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.btn:hover { background: var(--surface-sunk); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}

.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* --- Post list ------------------------------------------
   Bordered rows rather than a grid of cards. For a dense
   list, cards add visual weight without adding information. */

.post-list { border-top: var(--border); }

.post {
  display: block;
  padding: var(--space-4) 0;
  border-bottom: var(--border);
  text-decoration: none;
  color: inherit;
}

/* The filter sets the hidden attribute to remove a post. Because
   .post declares display: block, it would override the browser's
   built-in [hidden] rule and the post would stay visible — so we
   restore hiding with a selector specific enough to win. */
.post[hidden] { display: none; }

.post:hover .post-title { color: var(--accent); }

.post-title {
  font-family: var(--font-display);
  font-size: var(--size-h3);
  line-height: var(--leading-tight);
  margin-bottom: var(--space-1);
  transition: color var(--transition);
}

.post-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--ink-3);
  font-size: var(--size-caption);
}

.post-excerpt {
  color: var(--ink-2);
  font-size: var(--size-small);
  margin: var(--space-2) 0 0;
}

/* --- Detail grid ------------------------------------------
   Small labelled columns — the "technical stack" blocks on the
   certification pages. Reused across both, so it's a component
   rather than an inline style. */

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
  padding: var(--space-4);
  border: var(--border);
  border-radius: var(--radius);
  background: var(--surface-sunk);
}

.detail-grid h3 { font-size: var(--size-small); margin-bottom: var(--space-1); }
.detail-grid p  { margin: 0; color: var(--ink-2); font-size: var(--size-small); }

/* Skills line under a group of certificate links. */
.skills { color: var(--ink-2); font-size: var(--size-small); }
.skills strong { color: var(--ink); font-weight: var(--weight-bold); }

/* --- Tag --- */

.tag {
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
  color: var(--ink-2);
  font-size: var(--size-caption);
}

/* --- Empty state --- */

.empty {
  padding: var(--space-6) 0;
  text-align: center;
  color: var(--ink-3);
}

/* --- Form controls ---------------------------------------
   For the Reach out page. Inputs are the one place where
   browser defaults are actively unhelpful — they ignore your
   font and your color scheme unless told otherwise. */

.field { margin-bottom: var(--space-4); max-width: 34rem; }

.field label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--size-small);
  font-weight: var(--weight-bold);
}

.field .hint {
  margin: var(--space-1) 0 0;
  color: var(--ink-3);
  font-size: var(--size-caption);
}

input[type="text"],
input[type="email"],
textarea,
select {
  display: block;
  width: 100%;
  min-height: var(--control-height);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--fill-field);
  color: var(--ink);
  font: inherit;              /* inputs do NOT inherit font by default */
  font-size: var(--size-small);
  transition: border-color var(--transition);
}

textarea { min-height: 8rem; resize: vertical; line-height: var(--leading-body); }

input:hover, textarea:hover, select:hover { border-color: var(--ink-3); }

::placeholder { color: var(--ink-3); }

/* Validation state. Colour alone is not enough for colour-blind
   users, so pair it with text in .field .error. */
input[aria-invalid="true"],
textarea[aria-invalid="true"] { border-color: #B4342C; }

.field .error {
  margin: var(--space-1) 0 0;
  color: #B4342C;
  font-size: var(--size-caption);
}

/* --- Prose ------------------------------------------------
   Long-form body copy for blog posts. Everything is scoped
   under .prose so these generous margins never leak into the
   rest of the site. Wrap a post body in <div class="prose">. */

.prose { max-width: var(--measure); }

.prose > * + * { margin-top: var(--space-4); }

.prose h2 { margin-top: var(--space-6); }
.prose h3 { margin-top: var(--space-5); }

.prose p { margin-bottom: 0; }

.prose ul, .prose ol { padding-left: var(--space-4); }
.prose li + li { margin-top: var(--space-2); }

.prose blockquote {
  margin-left: 0;
  margin-right: 0;
  padding-left: var(--space-4);
  border-left: 2px solid var(--accent);
  border-radius: 0;                    /* single-sided borders stay square */
  color: var(--ink-2);
  font-family: var(--font-display);
  font-style: italic;
}

.prose code {
  padding: 2px var(--space-1);
  border-radius: var(--radius);
  background: var(--surface-sunk);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.9em;                    /* em, so it tracks the parent size */
}

.prose pre {
  padding: var(--space-4);
  border: var(--border);
  border-radius: var(--radius);
  background: var(--surface-sunk);
  overflow-x: auto;                    /* long lines scroll, not overflow */
  font-size: var(--size-caption);
  line-height: 1.5;
}

.prose pre code { padding: 0; background: none; font-size: inherit; }

.prose figure { margin: var(--space-5) 0; }
.prose figure img { border-radius: var(--radius); }

.prose figcaption {
  margin-top: var(--space-2);
  color: var(--ink-3);
  font-size: var(--size-caption);
}

.prose a { text-decoration: underline; }


/* ============================================================
   4. RESPONSIVE
   Only two breakpoints. Most of the layout already adapts on
   its own — fluid headings, max-width containers, flex-wrap —
   so these handle the few cases that genuinely need it.
   ============================================================ */

/* --- Tablet and below --- */
@media (max-width: 42rem) {
  body { padding: var(--space-5) var(--space-4); }

  /* The nav is the real pressure point: four labels rarely fit
     a phone. Rather than wrapping to a cramped second line, let
     the row scroll sideways and hide the scrollbar. The active
     tab is scrolled into view by the browser on load. */
  .tabs {
    gap: var(--space-3);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .tabs::-webkit-scrollbar { display: none; }

  :root { --avatar: 60px; }
}

/* --- Phone --- */
@media (max-width: 26rem) {
  body { padding: var(--space-4) var(--space-3); }

  :root { --avatar: 52px; }

  .identity { gap: var(--space-2); }

  /* Post metadata gets tight at this width; let it wrap. */
  .post-meta { flex-wrap: wrap; }
}
