*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0a0a0a;
  --text: #ffffff;
  --muted: #888888;
  --border: #1f1f1f;
  --sidebar-w: 230px;      /* change 1: slightly wider */
  --panel-w: 320px;
  --panel-expanded: 480px;
  --serif: 'Playfair Display', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* ─── Page Grid ─── */

.page-grid {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--panel-w);
  min-height: 100vh;
}

/* ─── Sidebar ─── */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px 32px;
  border-right: 1px solid var(--border);
}

.site-name {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.25;
  letter-spacing: -0.01em;
  transition: opacity 0.2s;
}

.site-name:hover { opacity: 0.7; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-link {
  font-size: 13px;
  color: var(--muted);
  transition: color 0.2s;
}

.nav-link:hover,
.nav-link.active { color: var(--text); }

/* Back link used on detail pages */
.back-link {
  font-size: 13px;
  color: var(--muted);
  transition: color 0.2s;
}

.back-link:hover { color: var(--text); }

/* ─── Center Content ─── */

.center { padding: 0; }

.section {
  border-top: 1px solid var(--border);
  padding: 64px 64px;
}

.section-intro {
  border-top: none;
  padding-top: 88px;
  padding-bottom: 88px;
}

.intro-text {
  font-size: 17px;
  font-weight: 300;
  line-height: 1.75;
  color: var(--text);
  max-width: 540px;
  margin-bottom: 32px;
}

.text-link {
  font-size: 13px;
  color: var(--muted);
  transition: color 0.2s;
}

.text-link:hover { color: var(--text); }

/* Section Header */

.section-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 36px;
}

.section-label {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: 0.01em;
}

.section-rule {
  display: block;
  width: 28px;
  height: 1px;
  background: var(--text);
}

/* ─── Work List — change 3: role subtitle + change 4: differentiation ─── */

.work-list {
  display: flex;
  flex-direction: column;
}

.work-item {
  display: flex;
  align-items: flex-start;   /* was baseline — needed for subtitle layout */
  justify-content: space-between;
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.2s;
  gap: 20px;
}

.work-list li:first-child .work-item {
  border-top: 1px solid var(--border);
}

.work-item:hover { opacity: 0.55; }

.work-item-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.work-title {
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
}

/* change 3: role shown under title */
.work-role {
  font-size: 12px;
  color: var(--muted);
  font-weight: 300;
  font-family: var(--sans);
  letter-spacing: 0.01em;
}

.work-year {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  flex-shrink: 0;
  padding-top: 6px; /* aligns to top of title */
}

/* change 4: Projects have italic serif titles to distinguish from Work */
.projects-list .work-title {
  font-style: italic;
}

/* ─── Skills ─── */

.skills-list {
  display: flex;
  flex-direction: column;
}

.skill-row {
  display: flex;
  gap: 40px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.skills-list li:first-child {
  border-top: 1px solid var(--border);
}

.skill-category {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  min-width: 120px;
  padding-top: 2px;
  flex-shrink: 0;
}

.skill-items {
  font-size: 14px;
  color: var(--text);
  font-weight: 300;
  line-height: 1.6;
}

/* ─── Resume ─── */

.resume-body { max-width: 600px; }

.resume-desc {
  font-size: 15px;
  font-weight: 300;
  color: var(--muted);
  margin-bottom: 28px;
  line-height: 1.7;
}

.resume-actions {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-bottom: 36px;
}

.resume-btn {
  font-size: 13px;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 20px;
  transition: border-color 0.2s, opacity 0.2s;
}

.resume-btn:hover { border-color: var(--text); opacity: 0.8; }

.resume-view {
  font-size: 13px;
  color: var(--muted);
  transition: color 0.2s;
}

.resume-view:hover { color: var(--text); }

.resume-preview-wrap {
  width: 100%;
  aspect-ratio: 8.5 / 11;
  border: 1px solid var(--border);
  overflow: hidden;
}

.resume-iframe {
  width: 100%;
  height: 100%;
  display: block;
}

/* ─── About ─── */

.about-body {
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-width: 540px;
}

.about-body p {
  font-size: 15px;
  font-weight: 300;
  line-height: 1.8;
  color: var(--text);
}

.about-italic {
  font-style: italic;
  color: var(--muted) !important;
}

/* ─── Education ─── */

.edu-list {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.edu-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.edu-degree {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.2;
}

.edu-school { font-size: 12px; color: var(--muted); }
.edu-note   { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ─────────────────────────────────────────────────────────
   Leadership section
──────────────────────────────────────────────────────────── */

.leadership-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.leadership-item {
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leadership-info {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.leadership-title {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.leadership-role {
  font-size: 12px;
  color: var(--muted);
  font-weight: 300;
}

.leadership-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  max-width: 540px;
}

/* ─────────────────────────────────────────────────────────
   Change 2: Right panel expands on hover/click to show form
   ───────────────────────────────────────────────────────── */

.contact-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: visible;      /* lets .contact-inner grow to the left */
}

.contact-inner {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 100%;            /* var(--panel-w) via grid column */
  background: var(--bg);
  border-left: 1px solid var(--border);
  z-index: 20;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 44px 40px;
  transition: width 0.42s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.2s;
  cursor: default;
}

/* Expand on hover or when pinned open */
.contact-panel:hover .contact-inner,
.contact-panel.pinned .contact-inner {
  width: var(--panel-expanded);
}

/* ── Panel header (always visible) ── */

.contact-header { flex-shrink: 0; }

.contact-title {
  font-family: var(--serif);
  font-size: 72px;
  font-weight: 400;
  line-height: 1.0;
  letter-spacing: -0.03em;
  color: var(--text);
  transition: font-size 0.35s ease;
}

.contact-panel:hover .contact-title,
.contact-panel.pinned .contact-title {
  font-size: 46px;
}

/* ── Expanding form section ── */

.contact-expand {
  flex: 1;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.25s ease 0.18s,
              transform 0.25s ease 0.18s;
  overflow-y: auto;
  /* hide scrollbar visually */
  scrollbar-width: none;
}

.contact-expand::-webkit-scrollbar { display: none; }

.contact-panel:hover .contact-expand,
.contact-panel.pinned .contact-expand {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.contact-panel-divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0 22px;
}

/* ── Contact form inside panel ── */

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}

.contact-form input,
.contact-form textarea {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 300;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
  width: 100%;
  -webkit-appearance: none;
}

.contact-form input::placeholder,
.contact-form textarea::placeholder { color: var(--muted); }

.contact-form input:focus,
.contact-form textarea:focus { border-color: #555; }

.form-submit {
  align-self: flex-start;
  background: var(--text);
  color: var(--bg);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 400;
  padding: 10px 24px;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
  letter-spacing: 0.02em;
}

.form-submit:hover { opacity: 0.8; }

/* ── Panel footer (always visible) ── */

.contact-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 16px;
}

.contact-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.contact-location,
.contact-time { font-size: 12px; color: var(--muted); }

.contact-arrow {
  font-size: 44px;
  color: var(--text);
  line-height: 1;
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.contact-panel:hover .contact-arrow {
  transform: translate(4px, -4px);
}

/* ─── Footer ─── */

.footer {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--panel-w);
  border-top: 1px solid var(--border);
  padding: 28px 0;
  align-items: center;
}

.footer-copy {
  padding-left: 32px;
  font-size: 12px;
  color: var(--muted);
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 0 64px;
}

.footer-links a {
  font-size: 12px;
  color: var(--muted);
  transition: color 0.2s;
}

.footer-links a:hover { color: var(--text); }

.footer-location {
  padding-right: 40px;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

/* ─────────────────────────────────────
   Detail Pages
   ───────────────────────────────────── */

.detail-grid {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.detail-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px 32px;
  border-right: 1px solid var(--border);
  /* sidebar-w already wider so name has room */
}

.detail-content {
  padding: 88px 80px 120px;
}

.detail-header {
  display: flex;
  align-items: baseline;
  gap: 20px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.detail-title {
  font-family: var(--serif);
  font-size: 80px;
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
}

.detail-year {
  font-size: 14px;
  color: var(--muted);
  flex-shrink: 0;
}

.detail-description {
  font-size: 18px;
  font-weight: 300;
  line-height: 1.75;
  color: var(--text);
  max-width: 680px;
  margin-bottom: 44px;
}

.detail-divider {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 36px 0;
}

.detail-meta {
  display: flex;
  gap: 64px;
  flex-wrap: wrap;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meta-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.meta-value {
  font-size: 15px;
  color: var(--text);
  font-weight: 400;
}

.detail-links {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.detail-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--text);
  padding-bottom: 3px;
  transition: opacity 0.2s;
}

.detail-link:hover { opacity: 0.55; }

.detail-bullets {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 680px;
}

.detail-bullets li {
  font-size: 14px;
  font-weight: 300;
  line-height: 1.75;
  color: var(--muted);
  padding-left: 16px;
  position: relative;
}

.detail-bullets li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--border);
}

/* Two-column body: text left, image bottom-right */
.detail-body {
  display: grid;
  grid-template-columns: 1fr 45%;
  gap: 48px;
}

.detail-main { min-width: 0; }

.detail-image-col {
  align-self: end; /* pins preview/image to the bottom of the grid row */
  min-width: 0;    /* prevent grid item from blowing out due to iframe's 1280px width */
}

.detail-screenshot {
  width: 100%;
  display: block;
  border: 1px solid var(--border);
  opacity: 0.88;
}

/* ── Browser mockup for work page website previews ── */

.preview-browser {
  display: block;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  overflow: hidden;
  background: #111;
  text-decoration: none;
  transition: border-color 0.22s, box-shadow 0.22s;
}

.preview-browser:hover {
  border-color: #484848;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
}

.preview-bar {
  background: #1c1c1c;
  height: 36px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 6px;
  border-bottom: 1px solid #2a2a2a;
  flex-shrink: 0;
}

.preview-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}
.preview-dot:nth-child(1) { background: #ff5f57; }
.preview-dot:nth-child(2) { background: #febc2e; }
.preview-dot:nth-child(3) { background: #28c840; }

.preview-url-bar {
  flex: 1;
  background: #111;
  border: 1px solid #2a2a2a;
  border-radius: 5px;
  height: 22px;
  margin: 0 10px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 10px;
  color: #555;
  font-family: var(--sans);
  overflow: hidden;
  white-space: nowrap;
}

/* Viewport height is set dynamically by JS to maintain 16:9.
   The iframe renders at 1280×720 and is CSS-scaled to fit the column. */
.preview-viewport {
  width: 100%;
  height: 280px; /* fallback; overwritten by scaleIframePreviews() */
  overflow: hidden;
  position: relative;
  background: #0d0d0d;
}

.detail-preview {
  width: 1280px;
  height: 720px;
  border: none;
  display: block;
  transform-origin: top left;
  pointer-events: none; /* click passes through to the <a> wrapper */
}

.preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: background 0.22s;
}

.preview-browser:hover .preview-overlay {
  background: rgba(0, 0, 0, 0.45);
}

.preview-visit {
  color: #fff;
  font-size: 13px;
  font-family: var(--sans);
  font-weight: 400;
  letter-spacing: 0.03em;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.22s, transform 0.22s;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 8px 18px;
  border-radius: 5px;
  backdrop-filter: blur(6px);
}

.preview-browser:hover .preview-visit {
  opacity: 1;
  transform: translateY(0);
}

/* ─────────────────────────────────────────────────────────
   LAPTOP  (≤ 2200px)
   Scale down for laptop & typical external monitor screens.
   Overridden by smaller breakpoints below.
──────────────────────────────────────────────────────────── */

@media (max-width: 2200px) {
  /* Main page */
  .section { padding: 44px 44px; }
  .section-intro { padding-top: 60px; padding-bottom: 60px; }
  .intro-text { font-size: 16px; }
  .work-title { font-size: 24px; }

  /* Contact panel */
  .contact-title { font-size: 50px; }
  .contact-panel:hover .contact-title,
  .contact-panel.pinned .contact-title { font-size: 34px; }
  .contact-inner { padding: 34px 28px; }

  /* Detail pages */
  .detail-content { padding: 52px 52px 80px; }
  .detail-title { font-size: 44px; }
  .detail-description { font-size: 16px; margin-bottom: 32px; }
}

/* ─────────────────────────────────────────────────────────
   TABLET  (≤ 1100px)
   Narrow the sidebar & contact panel; shrink fonts/padding.
──────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  :root {
    --sidebar-w: 170px;
    --panel-w: 220px;
    --panel-expanded: 360px;
  }

  /* Main layout */
  .section { padding: 40px 32px; }
  .section-intro { padding-top: 52px; padding-bottom: 52px; }
  .work-title { font-size: 22px; }
  .contact-title { font-size: 44px; }
  .contact-panel:hover .contact-title,
  .contact-panel.pinned .contact-title { font-size: 30px; }
  .contact-inner { padding: 32px 24px; }

  /* Detail pages */
  .detail-content { padding: 48px 40px 80px; }
  .detail-title { font-size: 38px; }
  .form-row { grid-template-columns: 1fr; gap: 11px; }

  /* Detail two-column: keep columns but proportion-based */
  .detail-body { gap: 36px; }
}

/* ─────────────────────────────────────────────────────────
   SMALL TABLET / LARGE PHONE  (≤ 860px)
   Drop the contact panel entirely; go two-column (sidebar + content).
──────────────────────────────────────────────────────────── */

@media (max-width: 860px) {
  /* Hide the sticky right panel — contact form moves to footer area */
  .contact-panel { display: none; }

  /* Main grid becomes two-column: sidebar + content */
  .page-grid {
    grid-template-columns: var(--sidebar-w) 1fr;
  }

  .section { padding: 44px 32px; }
  .intro-text { font-size: 16px; }
  .work-title { font-size: 26px; }

  /* Resume PDF preview: reduce height on smaller screens */
  .resume-iframe { height: 480px; }

  /* Detail body: switch to single column, hide browser mockup */
  .detail-body { grid-template-columns: 1fr; gap: 32px; align-items: start; }
  .detail-image-col { align-self: auto; }
  .preview-browser { display: none; }
}

/* ─────────────────────────────────────────────────────────
   MOBILE  (≤ 640px)
   Single-column stack. Sidebar becomes a top bar.
──────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  /* Stack everything vertically */
  .page-grid {
    display: flex;
    flex-direction: column;
  }

  /* Sidebar → stacked: name on top, scrollable nav row below */
  .sidebar {
    position: static;
    height: auto;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    border-right: none;
    border-bottom: none; /* nav row has its own border */
    gap: 0;
  }

  .site-name {
    font-size: 20px;
    line-height: 1.25;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
  }

  /* Nav: full-width horizontally scrollable strip */
  .sidebar-nav {
    flex-direction: row;
    gap: 0;
    margin-top: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
  }
  .sidebar-nav::-webkit-scrollbar { display: none; }
  .nav-link {
    flex-shrink: 0;
    padding: 12px 18px;
    font-size: 13px;
    white-space: nowrap;
    border-right: 1px solid var(--border);
  }
  .nav-link:last-child { border-right: none; }

  .center { flex: 1; }

  /* Sections */
  .section { padding: 40px 20px; }
  .section-intro { padding-top: 44px; padding-bottom: 44px; }
  .intro-text { font-size: 15px; }
  .section-label { font-size: 11px; }

  /* Work & project items */
  .work-title { font-size: 22px; }
  .work-item { padding: 16px 0; gap: 12px; }

  /* Skills */
  .skill-row { flex-direction: column; gap: 6px; padding: 14px 0; }
  .skill-category { font-size: 11px; min-width: unset; }

  /* Leadership */
  .leadership-title { font-size: 18px; }

  /* Resume iframe: compact height */
  .resume-iframe { height: 360px; }

  /* Education */
  .edu-degree { font-size: 20px; }

  /* Footer */
  .footer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 24px 20px;
  }
  .footer-copy, .footer-location { padding: 0; text-align: left; }
  .footer-links { padding: 0; justify-content: flex-start; flex-wrap: wrap; gap: 14px; }

  /* Contact panel: always-expanded at bottom */
  .contact-panel {
    display: block;
    position: static;
    height: auto;
    overflow: visible;
    border-top: 1px solid var(--border);
  }
  .contact-inner {
    position: static;
    width: 100% !important;
    height: auto;
    border-left: none;
    padding: 32px 20px 40px;
  }
  .contact-title { font-size: 36px; }
  .contact-expand {
    opacity: 1 !important;
    transform: none !important;
    pointer-events: all;
  }
  .contact-footer { margin-top: 20px; }

  /* Detail pages */
  .detail-grid { display: flex; flex-direction: column; }

  /* Detail sidebar: same stacked pattern as home page header */
  .detail-sidebar {
    position: static;
    height: auto;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    border-right: none;
    border-bottom: none;
    gap: 0;
    justify-content: flex-start;
  }

  /* Name block matches home page exactly */
  .detail-sidebar .site-name {
    font-size: 20px;
    line-height: 1.25;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
  }

  /* Back link styled like a nav strip item */
  .back-link {
    display: block;
    padding: 12px 18px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
  }

  .detail-content { padding: 36px 20px 72px; }
  .detail-title { font-size: 36px; letter-spacing: -0.01em; }
  .detail-description { font-size: 15px; }
  .detail-header { gap: 12px; margin-bottom: 24px; }
  .detail-meta { flex-direction: column; gap: 20px; }
  .detail-body { grid-template-columns: 1fr; gap: 28px; align-items: start; }
  .detail-image-col { align-self: auto; }

  /* Hide the browser mockup entirely on phone — visit link in content suffices */
  .preview-browser { display: none; }
  .detail-image-col { display: none; }
}
