/* ============================================================
   Tokens
   ============================================================ */
:root {
  --grid-gap:     #cdc5ba;      /* 1px gaps = visible border */
  --cell-bg:      #f7f4ef;      /* all cells except identity */
  --cell-pad:     clamp(1.25rem, 2.5vw, 2rem);

  --identity-bg:  #b85030;      /* terracotta */
  --identity-text:#ffffff;
  --identity-sub: rgba(255,255,255,0.6);

  --text:         #1a1714;
  --muted:        #6b6058;
  --accent:       #b85030;
  --accent-dark:  #8c3820;      /* print / hover */
  --border-inner: #e4ded6;

  --name-size: clamp(2.6rem, 3.5vw, 3.55rem);

  --font-display: "DM Serif Display", "Georgia", serif;
  --font-sans:    "Space Grotesk", system-ui, -apple-system, sans-serif;
  --font-mono:    ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;

  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
}

/* ============================================================
   Reset
   ============================================================ */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  font-family: var(--font-sans);
  font-size: 100%;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--grid-gap); /* bleeds as outer border */
  color: var(--text);
}

a {
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

/* ============================================================
   Mosaic grid
   ============================================================ */
.page {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  grid-template-rows: auto auto 1fr;
  grid-template-areas:
    "identity   experience  skills"
    "contact    experience  interests"
    "education  experience  projects";
  gap: 1px;           /* the 1px gaps show --grid-gap as hairlines */
  min-height: 100vh;
}

/* ============================================================
   Cells — base
   ============================================================ */
.cell {
  background: var(--cell-bg);
  padding: var(--cell-pad);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* Grid area assignments */
.cell--identity   { grid-area: identity; }
.cell--contact    { grid-area: contact; }
.cell--education  { grid-area: education; }
.cell--experience { grid-area: experience; }
.cell--skills     { grid-area: skills; }
.cell--interests  { grid-area: projects; }
.cell--projects   { grid-area: interests; }

/* ============================================================
   Identity cell
   ============================================================ */
.cell--identity {
  display: block;
  background: var(--identity-bg);
  color: var(--identity-text);
  justify-content: flex-end;
  min-height: 280px;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.identity-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.identity-header {
  display: flex;
  flex-wrap: wrap-reverse;
  align-items: center;
  justify-content: space-between;
  gap: 0;
}

.portrait {
  width: calc(var(--name-size) * 1.9);
  height: calc(var(--name-size) * 1.9);
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255, 255, 255, 0.3);
  display: block;
  flex-shrink: 0;
}

.name {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--name-size);
  font-weight: 400;
  line-height: 1.0;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  color: var(--identity-text);
}

.tagline {
  margin: var(--space-lg) 0 0 0;
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--identity-sub);
  line-height: 1.5;
}

.about {
  margin: var(--space-md) 0 0;
  font-size: 0.85rem;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.65;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: var(--space-md);
}

/* ============================================================
   Cell labels (section headings)
   ============================================================ */
.cell-label {
  margin: 0;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-inner);
}

/* ============================================================
   Contact list
   ============================================================ */
.contact-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  font-size: 0.85rem;
  color: var(--muted);
}

.contact-list a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--accent);
}

.contact-list a:hover {
  color: var(--accent);
}

/* ============================================================
   Entries
   ============================================================ */
.entry {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0 var(--space-md);
  align-items: start;
}

.entry-date {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  padding-top: 0.15rem;
  line-height: 1.6;
}

.entry-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.entry-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.entry-org {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.role-type {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-left: 0.4rem;
}

/* ============================================================
   Bullets
   ============================================================ */
.bullets {
  margin: var(--space-xs) 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.bullets li {
  position: relative;
  padding-left: 1rem;
  font-size: 0.875rem;
  line-height: 1.55;
}

.bullets li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 0.6rem;
  top: 0.32em;
}

/* ============================================================
   Lede
   ============================================================ */
.lede {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.65;
}

/* ============================================================
   Skill tags
   ============================================================ */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tags li {
  border: 1.5px solid var(--accent);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.18rem 0.6rem;
  border-radius: 2px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ============================================================
   Interests
   ============================================================ */
.interest-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  font-size: 0.875rem;
  color: var(--muted);
}

.interest-list li::before {
  content: "— ";
  color: var(--accent);
  font-weight: 700;
}

/* ============================================================
   Responsive — tablet (≤1024px): 2-column grid
   ============================================================ */
@media (max-width: 1024px) {
  .page {
    grid-template-columns: 1fr 2fr;
    grid-template-rows: auto;
    grid-template-areas:
      "identity    experience"
      "contact     experience"
      "education   experience"
      "skills      interests"
      "projects    projects";
  }

  .cell--projects {
    grid-column: 1 / -1; /* span both columns */
  }

  .cell--identity {
    min-height: 200px;
    --name-size: clamp(2rem, 5vw, 3rem); /* portrait scales with this too */
  }

  .identity-header {
    flex-wrap: wrap-reverse;  /* fallback: stack if cell is too narrow */
  }

  .portrait {
    width: calc(var(--name-size) * 2.2);
    height: calc(var(--name-size) * 2.2);
  }
}

/* ============================================================
   Responsive — mobile (≤640px): single column
   ============================================================ */
@media (max-width: 640px) {
  body {
    background: var(--cell-bg);
  }

  .page {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-height: auto;
  }

  .cell--identity   { order: 1; }
  .cell--contact    { order: 2; }
  .cell--experience { order: 3; }
  .cell--education  { order: 4; }
  .cell--skills     { order: 5; }
  .cell--interests  { order: 6; }
  .cell--projects   { order: 7; }

  .cell--identity {
    min-height: auto;
    justify-content: flex-start;
    padding: var(--cell-pad);
    --name-size: clamp(2.4rem, 10vw, 3.2rem); /* larger on mobile — full width available */
  }

  .identity-header {
    justify-content: flex-start;
    gap: var(--space-lg);
  }

  .portrait {
    width: calc(var(--name-size) * 2.5);
    height: calc(var(--name-size) * 2.5);
  }

  .name {
    font-size: clamp(2.4rem, 12vw, 3.5rem);
  }

  /* Flatten entry date-column on small screens */
  .entry {
    grid-template-columns: 4.5rem 1fr;
    gap: 0 0.75rem;
  }

  .entry-date {
    font-size: 0.7rem;
  }

  /* Wrap tags more comfortably */
  .tags li {
    font-size: 0.75rem;
  }
}

/* ============================================================
   Print / Save as PDF
   Collapses grid to single column, flattens identity cell
   ============================================================ */
@page {
  margin: 14mm;
}

@media print {
  html { font-size: 9.5pt; line-height: 1.5; }

  body { background: #ffffff; }

  .page {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: auto;
  }

  /* Print order: identity → contact → experience → education → skills → interests → projects */
  .cell--identity   { order: 1; }
  .cell--contact    { order: 2; }
  .cell--experience { order: 3; }
  .cell--education  { order: 4; }
  .cell--skills     { order: 5; }
  .cell--interests  { order: 6; }
  .cell--projects   { order: 7; }

  .cell {
    background: #ffffff;
    padding: 0.75rem 0;
    gap: 0.75rem;
    border-bottom: 1px solid #e0d8ce;
  }

  .cell--identity {
    background: #ffffff;
    min-height: auto;
    justify-content: flex-start;
    border-bottom: 2px solid #1a1714;
    flex-direction: row;
    align-items: baseline;
    gap: 1.5rem;
    flex-wrap: wrap;
  }

  .identity-content {
    display: flex;
    align-items: center;
    gap: 2rem;
  }

  .identity-header {
    justify-content: flex-start;
  }

  .name {
    font-size: 22pt;
    color: #111111;
  }

  .tagline {
    color: #444444;
    text-transform: none;
    letter-spacing: 0;
    font-size: 9pt;
  }

  .cell-label {
    color: var(--accent-dark);
    border-bottom-color: #d0c8be;
  }

  .entry-date { color: var(--accent-dark); }

  .bullets li::before { color: var(--accent-dark); }

  .tags li {
    border-color: var(--accent-dark);
    color: var(--accent-dark);
  }

  .interest-list li::before { color: var(--accent-dark); }

  .entry {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
