:root {
  --bg: #f6f8fa;
  --ink: #24292f;
  --muted: #57606a;
  --accent: #0969da;
  --accent-soft: rgba(9, 105, 218, 0.12);
  --hero-accent: rgba(9, 105, 218, 0.55);
  --panel: #ffffff;
  --line: #d0d7de;
  --img-background: #f8fbfe;
  --shadow: 0 12px 32px rgba(31, 35, 40, 0.12);
  --radius: 24px;
  --page-pad: clamp(1.5rem, 6vw, 6rem);
  --grid-max: calc(320px + 520px + 3rem);
  --profile-size: clamp(112px, 16vw, 144px);
  --content-gap: 1.5rem;
}

* {
  box-sizing: border-box;
}

img {
  max-width: 100%;
  height: auto;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--ink);
  background: var(--bg);
  padding: 0;
  padding-top: calc(var(--header-height, 160px) + var(--content-gap));
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* --- Header --- */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 30;
  display: flex;
  justify-content: center;
  text-align: center;
  padding: 1.4rem var(--page-pad);
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(7px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  position: relative;
  width: min(100%, var(--grid-max));
  margin: 0 auto;
  display: grid;
  justify-items: center;
}

.header-eyebrow {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  letter-spacing: 0.2rem;
  text-transform: uppercase;
  color: var(--muted);
}

.site-header h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(2rem, 4vw, 3.4rem);
  font-weight: 700;
  white-space: nowrap;
  width: 100%;
  max-width: 100%;
}

.header-role {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  color: var(--muted);
  width: 100%;
  max-width: 100%;
}

.header-intro {
  margin: 0;
  font-size: 1.02rem;
  width: 100%;
  max-width: 100%;
  text-align: left;
  padding: 0.55rem 0.9rem 0.55rem 1.1rem;
  background: #f6f8fa;
  border-left: 4px solid var(--hero-accent);
  box-shadow: 0 6px 16px rgba(31, 35, 40, 0.08);
}

.lang-switch {
  position: absolute;
  top: 1.1rem;
  right: clamp(1rem, 4vw, 3rem);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  font-size: 0.65rem;
  color: var(--muted);
}

.lang-indicator {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.lang-link {
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.08rem;
  text-transform: uppercase;
  font-weight: 500;
}

.lang-link.is-active {
  color: var(--ink);
  font-weight: 700;
}

.lang-sep {
  color: var(--line);
}

/* --- Page Layout --- */

.page {
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(360px, 520px);
  gap: clamp(1.5rem, 3vw, 3rem);
  padding: 0 var(--page-pad) 3rem;
  align-items: stretch;
  justify-content: center;
  max-width: calc(var(--grid-max) + (2 * var(--page-pad)));
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.side-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  align-self: stretch;
}

/* --- Detail Card --- */

.detail-card {
  position: sticky;
  top: calc(var(--header-height, 160px) + 1rem);
  width: 100%;
  padding: 1.6rem 1.8rem;
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  height: 480px;
  display: flex;
  flex-direction: column;
}

.detail-year {
  display: inline-block;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.detail-card h2 {
  margin: 0 0 0.4rem;
  font-size: 1.6rem;
}

.detail-card h3 {
  margin: 0 0 0.8rem;
  font-size: 1rem;
  color: var(--muted);
  font-weight: 500;
}

.detail-card p {
  margin: 0 0 1rem;
  line-height: 1.6;
}

.detail-role {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
}

.detail-subroles {
  margin: 0 0 0.8rem;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 500;
}

.detail-placeholder {
  display: none;
  padding: 0.4rem;
  flex: 1;
}

.detail-placeholder img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: 16px;
  object-fit: contain;
}

.detail-card.has-placeholder {
  padding: 0.8rem;
}

.detail-card.has-placeholder .detail-placeholder {
  display: block;
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-card.has-placeholder .detail-placeholder img {
  width: auto;
  height: auto;
}

.detail-card.has-placeholder .detail-body {
  display: none;
}

.detail-details {
  margin: 0 0 1rem;
  line-height: 1.6;
  color: var(--muted);
}

.detail-details p {
  margin: 0 0 0.8rem;
}

.detail-details p:last-child {
  margin-bottom: 0;
}

.detail-details ul,
.detail-details ol {
  margin: 0 0 0.8rem;
  padding-left: 1.1rem;
  list-style-position: outside;
}

.detail-details li {
  margin: 0 0 0.4rem;
}

.detail-details li:last-child {
  margin-bottom: 0;
}

.detail-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.detail-badges-title {
  margin: auto 0 0.5rem;
  font-size: 0.7rem;
  letter-spacing: 0.05rem;
  color: #8c959f;
  font-weight: 600;
  padding-left: 0.2rem;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0 0.2rem 0.4rem;
}

.detail-badges img {
  width: clamp(36px, 10vw, 44px);
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  background: var(--img-background);
  object-fit: cover;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.detail-tags span {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: #f6f8fa;
  color: var(--accent);
  border: 1px solid var(--line);
  font-weight: 600;
}

.detail-tags.is-empty {
  display: none;
}

/* --- Timeline --- */

.timeline-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-self: stretch;
}

.timeline-surface {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.timeline-scroll {
  padding: 2rem 2rem 2.4rem;
}

.timeline-spacer {
  height: var(--timeline-spacer-height, 0px);
}

.timeline {
  position: relative;
  float: none;
  clear: both;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 0.5rem 0 0;
  border: 0;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--line);
}

.timeline-item {
  position: relative;
  padding-left: 56px;
  margin-bottom: 2.4rem;
  transition: transform 180ms ease;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-marker {
  position: absolute;
  left: 8px;
  top: 6px;
  width: 18px;
  height: 18px;
  background: var(--panel);
  border-radius: 50%;
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  transition: transform 180ms ease, background 180ms ease;
}

.timeline-marker::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
}

.timeline-content h3 {
  margin: 0.25rem 0 0.2rem;
  font-size: 1.2rem;
}

.timeline-content h4 {
  margin: 0 0 0.7rem;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 500;
}

.timeline-description p {
  margin: 0 0 0.8rem;
  line-height: 1.6;
}

.timeline-description p:last-child {
  margin-bottom: 0;
}

.timeline-details-source {
  display: none;
}

.timeline-year {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08rem;
}

.timeline-tags span {
  display: inline-block;
  margin-right: 0.4rem;
  margin-bottom: 0.4rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  background: #f6f8fa;
  border-radius: 999px;
  color: var(--muted);
  border: 1px solid var(--line);
}

.timeline-tags {
  margin-top: 0;
  padding-top: 0.8rem;
}

.timeline-badges-title {
  margin: 0.8rem 0 0.5rem;
  font-size: 0.65rem;
  letter-spacing: 0.05rem;
  color: #8c959f;
  font-weight: 600;
  display: none;
}

.timeline-badges {
  display: none;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.timeline-badges--no-title {
  margin-top: 2.1rem;
}

.timeline-badges img {
  width: clamp(30px, 9vw, 38px);
  aspect-ratio: 1 / 1;
  border-radius: 9px;
  background: var(--img-background);
  object-fit: cover;
}

.timeline-item.is-active .timeline-marker {
  border-color: var(--hero-accent);
  transform: scale(1.1);
}

.timeline-item.is-active .timeline-marker::after {
  background: var(--hero-accent);
}

.timeline-item.is-active .timeline-content {
  background: rgba(9, 105, 218, 0.06);
  border-radius: 16px;
  padding: 0.6rem 0.8rem;
  margin-left: -0.8rem;
  color: var(--ink);
}

.timeline-item:not(.is-active) .timeline-content,
.timeline-item:not(.is-active) .timeline-year,
.timeline-item:not(.is-active) .timeline-content h3,
.timeline-item:not(.is-active) .timeline-content h4,
.timeline-item:not(.is-active) .timeline-content .timeline-description,
.timeline-item:not(.is-active) .timeline-content .timeline-description p {
  color: #8c959f;
}

.timeline-private {
  margin-top: 2.4rem;
  padding: 0 0.5rem 3rem 56px;
  color: var(--muted);
}

.timeline-private-inner {
  margin: 0;
  padding: 2.4rem 0 2.4rem;
  border-top: 1px solid var(--line);
}

.timeline-private h3 {
  margin: 0 0 0.6rem;
  font-size: 1.2rem;
  color: var(--ink);
}

.timeline-private h4 {
  margin: 0 0 0.7rem;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 500;
}

.timeline-private p {
  margin: 0 0 0.8rem;
  line-height: 1.6;
}

/* --- Legal Page --- */

.page-legal {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--page-pad) 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.legal-card {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: clamp(1.5rem, 4vw, 2.4rem);
}

.legal-card h1 {
  margin: 0 0 1rem;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
}

.legal-card h2 {
  margin: 1.6rem 0 0.6rem;
  font-size: 1.2rem;
  scroll-margin-top: calc(var(--header-height, 160px) + 1rem);
}

.legal-card p {
  margin: 0 0 0.9rem;
  line-height: 1.6;
}

.legal-card ul {
  margin: 0 0 0.9rem;
  padding-left: 1.1rem;
}

.legal-card pre {
  margin: 0 0 1rem;
  padding: 1rem 1.1rem;
  background: #0f1419;
  color: #f2f5f8;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.legal-card pre code {
  font-size: 0.9rem;
  line-height: 1.5;
  display: block;
}

/* --- Footer --- */

.site-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem var(--page-pad) 2.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}

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

/* --- Profile Sequence --- */

#profile-sequence {
  position: absolute;
  right: calc((var(--profile-size) + 2rem) * -1);
  top: 50%;
  transform: translateY(-50%);
  width: var(--profile-size);
  height: var(--profile-size);
  border-radius: 50%;
  border: 3px solid var(--img-background);
  box-shadow: var(--shadow);
  overflow: hidden; /* Fix for Safari border-radius clipping */
  transform: translateY(-50%) translateZ(0); /* Fix for Safari composite layer */
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 1;
}

#profile-sequence img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

@media (min-width: 1280px) {
  #profile-sequence {
    display: flex !important;
  }
}

/* --- Responsive Media Queries --- */

@media (max-width: 900px) {
  #profile-sequence {
    display: none;
  }

  .header-intro {
    display: none !important;
  }

  .timeline-description {
    display: block;
  }

  .page {
    grid-template-columns: 1fr;
    padding-bottom: 2.5rem;
  }

  .side-panel {
    display: none !important;
  }

  /* Remove highlighting for active items */
  .timeline-item.is-active .timeline-content {
    background: transparent;
    border-radius: 0;
    margin-left: 0;
    padding: 0.6rem 0.8rem;
    color: var(--ink);
  }

  .timeline-item .timeline-content {
    padding: 0.6rem 0.8rem;
  }

  .timeline-item.is-active .timeline-marker {
    border-color: var(--line);
    transform: none;
  }

  .timeline-item.is-active .timeline-marker::after {
    background: var(--line);
  }

  /* Ensure text is readable even if item is not active on small screens */
  .timeline-item:not(.is-active) .timeline-content,
  .timeline-item:not(.is-active) .timeline-year,
  .timeline-item:not(.is-active) .timeline-content h3,
  .timeline-item:not(.is-active) .timeline-content h4,
  .timeline-item:not(.is-active) .timeline-content .timeline-description,
  .timeline-item:not(.is-active) .timeline-content .timeline-description p {
    color: var(--ink);
  }

  .detail-card {
    display: none;
  }

  .timeline-private {
    display: block;
    padding: 0 0.5rem 2rem 56px;
  }

  .timeline-private h3,
  .timeline-private h4,
  .timeline-private p,
  .timeline-private .timeline-tags span {
    color: var(--ink);
  }

  .timeline-surface {
    box-shadow: var(--shadow);
  }

  .timeline-spacer {
    display: none !important;
  }

  .timeline-badges-title {
    display: block;
  }

  .timeline-badges {
    display: flex;
  }
}

@media (max-width: 560px) {
  .site-header h1 {
    white-space: normal;
  }

  .detail-badges {
    display: none !important;
  }

  .detail-card {
    height: clamp(240px, 38vh, 320px);
  }
}

/*
   Mobile Landscape Override
   Targeting devices that are wide but short (landscape phones/small tablets)
*/
@media (max-width: 1200px) and (orientation: landscape) and (max-height: 800px) {
  body {
    padding-top: 0;
  }

  .site-header {
    position: sticky;
    top: 0;
    padding: 0.4rem var(--page-pad);
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.95);
    height: auto;
    min-height: 50px;
  }

  .site-header h1 {
    font-size: 1.1rem;
    margin: 0;
    white-space: nowrap;
  }

  .header-eyebrow,
  .header-role,
  .header-intro {
    display: none !important;
  }

  .lang-switch {
    top: 50%;
    transform: translateY(-50%);
    right: var(--page-pad);
  }

  /* Force hide the Detail View in landscape */
  .side-panel {
    display: none !important;
  }

  .page {
    grid-template-columns: 1fr;
    display: block;
    padding-top: 1rem;
  }

  .page-legal {
    padding-top: 1rem;
  }

  /* Force show Timeline Description */
  .timeline-description {
    display: block !important;
  }

  /*
     Reset active highlighting and ensure consistent layout
     for ALL items to prevent jumping
  */
  .timeline-item .timeline-content,
  .timeline-item.is-active .timeline-content {
    background: transparent;
    border-radius: 0;
    margin-left: 0;
    padding: 0.6rem 0.8rem;
    color: var(--ink);
  }

  .timeline-item.is-active .timeline-marker {
    border-color: var(--line);
    transform: none;
  }

  .timeline-item.is-active .timeline-marker::after {
    background: var(--line);
  }

  /* Improve text contrast for all items in this view (redundant safety check) */
  .timeline-item:not(.is-active) .timeline-content,
  .timeline-item:not(.is-active) .timeline-year,
  .timeline-item:not(.is-active) .timeline-content h3,
  .timeline-item:not(.is-active) .timeline-content h4,
  .timeline-item:not(.is-active) .timeline-content .timeline-description,
  .timeline-item:not(.is-active) .timeline-content .timeline-description p {
    color: var(--ink);
  }

  .timeline-content h3 {
    font-size: 1.1rem;
  }

  .timeline-content h4 {
    font-size: 0.95rem;
  }

  .timeline-description p {
    line-height: 1.5;
    font-size: 0.95rem;
  }

  .timeline-item {
    margin-bottom: 1.5rem;
  }

  .timeline-badges-title {
    display: block;
  }

  .timeline-badges {
    display: flex;
  }
}
