/* ==========================================================================
   Portfolio — Apple-inspired design system
   Photography-first restraint: single Action Blue accent, tight headlines,
   17px body, full-bleed light/dark tiles, one product shadow.
   ========================================================================== */

:root {
  /* Color — single accent, near-black ink, parchment rhythm */
  --ink: #1d1d1f;
  --body: #1d1d1f;
  --body-muted: #6e6e73;
  --body-faint: #86868b;
  --accent: #0066cc;
  --accent-focus: #0071e3;
  --accent-on-dark: #2997ff;

  --canvas: #ffffff;
  --parchment: #f5f5f7;
  --surface-pearl: #fafafc;
  --tile-dark: #1d1d1f;
  --tile-dark-2: #272729;
  --on-dark: #ffffff;
  --body-on-dark: #c7c7cc;

  --hairline: #d2d2d7;
  --hairline-soft: #e8e8ed;
  --divider-soft: #f0f0f0;

  /* Radius */
  --r-sm: 8px;
  --r-md: 11px;
  --r-lg: 18px;
  --r-pill: 9999px;

  /* Spacing — 8px base */
  --space-xxs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 17px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-section: 88px;

  /* Type */
  --font-sans: -apple-system, BlinkMacSystemFont, system-ui, 'Inter',
    'Segoe UI', 'Helvetica Neue', sans-serif;

  /* Single product shadow + dialog elevation */
  --shadow-product: 0 5px 30px rgba(0, 0, 0, 0.22);
  --shadow-card-hover: 0 6px 20px rgba(0, 0, 0, 0.08);

  /* Signature Apple easing */
  --ease-apple: cubic-bezier(0.32, 0.72, 0, 1);

  --nav-height: 48px;
}

/* ==========================================================================
   Base
   ========================================================================== */

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

html {
  font-size: 17px;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 12px);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.47;
  letter-spacing: -0.01em;
  color: var(--body);
  background-color: var(--canvas);
  padding-top: var(--nav-height);
  overflow-x: hidden; /* guard against accidental horizontal scroll on mobile */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ink);
}

p {
  color: var(--body-muted);
}

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

a:hover {
  text-decoration: underline;
}

::selection {
  background: rgba(0, 102, 204, 0.18);
}

/* ==========================================================================
   Frosted fixed nav
   ========================================================================== */

.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  z-index: 200;
  background: rgba(245, 245, 247, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.site-nav__inner {
  max-width: 980px;
  margin: 0 auto;
  height: 100%;
  padding: 0 var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.site-nav__brand {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  flex-shrink: 0;
}

.site-nav__brand:hover {
  text-decoration: none;
  opacity: 0.7;
}

.site-nav__links {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  list-style: none;
}

.site-nav__links a {
  font-size: 0.82rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--body-muted);
  white-space: nowrap;
  transition: color 0.2s ease;
}

.site-nav__links a:hover {
  color: var(--ink);
  text-decoration: none;
}

.site-nav__links a.active {
  color: var(--accent);
}

@media (max-width: 600px) {
  .site-nav__inner {
    padding: 0 var(--space-md);
  }
  .site-nav__links {
    gap: var(--space-md);
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .site-nav__links::-webkit-scrollbar {
    display: none;
  }
  .site-nav__links a {
    font-size: 0.78rem;
  }
}

/* ==========================================================================
   Tiles — full-bleed alternating surfaces (color change = divider)
   ========================================================================== */

.tile {
  padding: var(--space-section) 0;
}

.tile--canvas {
  background: var(--canvas);
}

.tile--parchment {
  background: var(--parchment);
}

.tile--dark {
  background: var(--tile-dark);
  color: var(--on-dark);
}

.tile--dark h1,
.tile--dark h2,
.tile--dark h3,
.tile--dark h4 {
  color: var(--on-dark);
}

.tile--dark p {
  color: var(--body-on-dark);
}

.tile--dark a {
  color: var(--accent-on-dark);
}

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
  padding: calc(var(--space-section) + 16px) 0 var(--space-section);
  background: var(--canvas);
}

.hero__content {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2xl);
  align-items: center;
}

.hero__title {
  font-size: clamp(2.6rem, 6vw, 3.5rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: var(--space-sm);
}

.hero__subtitle {
  font-size: clamp(1.25rem, 3vw, 1.6rem);
  color: var(--body-muted);
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-xxs);
}

.hero__affiliation {
  font-size: 1.05rem;
  color: var(--body-muted);
  font-weight: 400;
  margin-top: var(--space-xs);
}

.hero__image-wrapper img {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-product);
}

/* ==========================================================================
   Section scaffolding
   ========================================================================== */

.section__header {
  margin-bottom: var(--space-xl);
}

.section__title {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.tile--dark .section__title {
  color: var(--on-dark);
}

.section__description {
  font-size: 1rem;
  color: var(--body-muted);
  line-height: 1.6;
  margin-bottom: var(--space-xl);
  text-wrap: pretty;
}

.section__description strong {
  color: var(--ink);
  font-weight: 600;
}

/* ==========================================================================
   Profile (portfolio page)
   ========================================================================== */

.profile__content {
  display: flex;
  flex-direction: column;
}

.profile__item {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: var(--space-lg);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--hairline-soft);
  align-items: baseline;
}

.profile__item:last-child {
  border-bottom: none;
}

.profile__label {
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.profile__value {
  font-size: 1rem;
  color: var(--body-muted);
  line-height: 1.5;
}

/* ==========================================================================
   News
   ========================================================================== */

.news-list {
  list-style: none;
}

.news-item {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: var(--space-lg);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--hairline-soft);
  align-items: baseline;
}

.news-item:last-child {
  border-bottom: none;
}

.news-date {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--body-faint);
  font-variant-numeric: tabular-nums;
}

.news-content {
  font-size: 1rem;
  color: var(--body);
  line-height: 1.5;
}

/* ==========================================================================
   Experience categories
   ========================================================================== */

.experience__categories {
  display: flex;
  flex-direction: column;
}

/* Each category reads as a labelled block: label on the left, content right,
   separated by a hairline — clear visual grouping instead of a dense stack. */
.experience-category {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: var(--space-xl);
  padding: var(--space-xl) 0;
  border-top: 1px solid var(--hairline-soft);
}

.experience-category:first-child {
  border-top: none;
  padding-top: 0;
}

.experience-category:last-child {
  padding-bottom: 0;
}

.experience-category__title {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0;
}

.experience-category__body {
  min-width: 0;
}

/* Dark tile (none today) keeps the label readable */
.tile--dark .experience-category {
  border-top-color: rgba(255, 255, 255, 0.12);
}

/* Simple list (education / internships) */
.simple-list {
  list-style: none;
}

.simple-list li {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: var(--space-lg);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--hairline-soft);
  align-items: baseline;
}

.simple-list li:last-child {
  border-bottom: none;
}

.simple-list .period {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--body-faint);
  font-variant-numeric: tabular-nums;
}

.simple-list .content {
  font-size: 1rem;
  color: var(--body);
  line-height: 1.5;
}

.simple-list .content .inline-link,
.simple-text a {
  color: var(--accent);
  font-weight: 400;
}

/* History entry — org / detail / lab stacked on separate lines */
.entry {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.entry__org {
  width: fit-content;
  max-width: 100%;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.35;
}

.entry__detail {
  font-size: 0.92rem;
  color: var(--body-muted);
  line-height: 1.5;
}

.entry__lab {
  width: fit-content;
  max-width: 100%;
  font-size: 0.92rem;
  color: var(--body-muted);
  text-decoration: none;
  line-height: 1.4;
}

/* External-link affordance only on the linked variants */
a.entry__org::after,
a.entry__lab::after {
  content: "\2197"; /* ↗ */
  margin-left: 4px;
  font-size: 0.72em;
  color: var(--body-faint);
  vertical-align: 0.12em;
  transition: color 0.2s ease;
}

a.entry__org:hover,
a.entry__lab:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

a.entry__org:hover::after,
a.entry__lab:hover::after {
  color: var(--accent);
}

/* Platform ranks summary — clean inline text, no box */
.platform-ranks {
  font-size: 0.92rem;
  color: var(--body-muted);
  margin-bottom: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-xxs);
}

.platform-ranks .rank-item {
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.platform-ranks strong {
  color: var(--ink);
  font-weight: 600;
}

/* ==========================================================================
   Competition list — clean hairline-divided rows (whole row clickable)
   ========================================================================== */

.comp-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--hairline-soft);
}

.comp-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-sm);
  border-bottom: 1px solid var(--hairline-soft);
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background 0.2s ease;
}

.comp-row:hover {
  background: rgba(0, 0, 0, 0.03);
}

.comp-row:active {
  background: rgba(0, 0, 0, 0.05);
}

/* Disclosure chevron — signals "tap for details" (Apple list-row pattern) */
.comp-row::after {
  content: "\203A"; /* › */
  flex-shrink: 0;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--hairline);
  transition: color 0.2s ease, transform 0.2s var(--ease-apple);
}

.comp-row:hover::after {
  color: var(--accent);
  transform: translateX(3px);
}

.comp-row__main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1 1 auto;
}

.comp-row__name {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.3;
  overflow-wrap: anywhere;
  transition: color 0.2s ease;
}

.comp-row:hover .comp-row__name {
  color: var(--accent);
}

.comp-row__meta {
  font-size: 0.85rem;
  color: var(--body-muted);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.comp-row__result {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.comp-row__rank {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.comp-row__medal {
  font-size: 1.3rem;
  line-height: 1;
}

/* ==========================================================================
   Skills (dark tile)
   ========================================================================== */

.skills__grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.skill-category__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.skill-category__header i {
  display: none;
}

.skill-category__header h3 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--on-dark);
}

.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.skill-tag {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--r-pill);
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--on-dark);
}

/* ==========================================================================
   Links
   ========================================================================== */

.links__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-md);
}

.link-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-xxs);
  padding: var(--space-lg) var(--space-lg) calc(var(--space-lg) - 2px);
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  text-decoration: none;
  transition: border-color 0.25s var(--ease-apple);
}

.link-card:hover {
  border-color: var(--ink);
  text-decoration: none;
}

.link-card:active {
  transform: scale(0.99);
}

.link-card::after {
  content: "\2197"; /* ↗ */
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  font-size: 0.85rem;
  color: var(--body-faint);
  transition: color 0.25s var(--ease-apple), transform 0.25s var(--ease-apple);
}

.link-card:hover::after {
  color: var(--accent);
  transform: translate(2px, -2px);
}

.link-card__label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--body-faint);
}

.link-card__value {
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.link-card:hover .link-card__value {
  color: var(--accent);
}

/* ==========================================================================
   Scroll-to-top — circular translucent control
   ========================================================================== */

.scroll-to-top {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  width: 44px;
  height: 44px;
  background: rgba(210, 210, 215, 0.7);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: none;
  border-radius: var(--r-pill);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.3s var(--ease-apple),
    visibility 0.3s var(--ease-apple), transform 0.3s var(--ease-apple),
    background 0.2s ease;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scroll-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-to-top:hover {
  background: rgba(190, 190, 196, 0.9);
}

.scroll-to-top:active {
  transform: scale(0.92);
}

.scroll-icon {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  background: var(--parchment);
  padding: var(--space-2xl) 0;
  text-align: center;
}

.footer p {
  font-size: 0.78rem;
  color: var(--body-faint);
  margin: 0;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   Competition trigger (clickable comp names)
   ========================================================================== */

/* Inline "open details" trigger — dotted underline + ⓘ marks it as a
   modal trigger, visually distinct from plain text and from nav links. */
.comp-trigger {
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.comp-trigger::after {
  content: "\2009\24D8"; /* thin space + ⓘ */
  font-size: 0.82em;
  vertical-align: 0.08em;
}

.comp-trigger:hover {
  text-decoration-style: solid;
}

/* ==========================================================================
   Modal — smooth scale + fade
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s var(--ease-apple),
    visibility 0.35s var(--ease-apple);
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.94);
  width: calc(100% - 2 * var(--space-lg));
  max-width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--canvas);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-product);
  z-index: 101;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s var(--ease-apple),
    transform 0.35s var(--ease-apple), visibility 0.35s var(--ease-apple);
}

.modal.is-open,
.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.modal.is-open {
  transform: translate(-50%, -50%) scale(1);
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-lg) var(--space-lg) var(--space-md);
}

.modal__title {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.3;
  margin: 0;
}

.modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: var(--parchment);
  border: none;
  border-radius: var(--r-pill);
  font-size: 1.2rem;
  line-height: 1;
  color: var(--body-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s var(--ease-apple);
}

.modal__close:hover {
  background: var(--hairline-soft);
  color: var(--ink);
}

.modal__close:active {
  transform: scale(0.9);
}

.modal__body {
  padding: 0 var(--space-lg) var(--space-md);
}

.modal__section {
  margin-bottom: var(--space-md);
}

.modal__section:last-child {
  margin-bottom: 0;
}

.modal__label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--body-faint);
  margin-bottom: var(--space-xxs);
}

.modal__text {
  font-size: 0.95rem;
  color: var(--body);
  line-height: 1.6;
  margin: 0;
}

.modal__note {
  font-size: 0.92rem;
  color: var(--body-muted);
  line-height: 1.6;
  margin: var(--space-md) 0 0;
  padding-top: var(--space-md);
  border-top: 1px solid var(--hairline-soft);
}

.modal__footer {
  padding: 0 var(--space-lg) var(--space-lg);
}

.modal__link {
  display: inline-block;
  padding: 11px 22px;
  background: var(--accent);
  border: none;
  border-radius: var(--r-pill);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.15s var(--ease-apple);
}

.modal__link:hover {
  background: var(--accent-focus);
  text-decoration: none;
}

.modal__link:active {
  transform: scale(0.95);
}

.modal__url-note {
  font-size: 0.88rem;
  color: var(--body-faint);
  margin: 0;
  line-height: 1.55;
}

/* Keyboard focus ring */
:focus-visible {
  outline: 2px solid var(--accent-focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ==========================================================================
   Scroll reveal (subtle, JS-gated, motion-safe)
   ========================================================================== */

html.js .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s var(--ease-apple), transform 0.6s var(--ease-apple);
  will-change: opacity, transform;
}

html.js .reveal.in-view {
  opacity: 1;
  transform: none;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
  :root {
    --space-section: 56px;
  }

  .container {
    padding: 0 var(--space-md);
  }

  .hero__content {
    grid-template-columns: 1fr;
    text-align: center;
    gap: var(--space-xl);
  }

  .hero__image {
    order: -1;
  }

  .hero__image-wrapper {
    margin: 0 auto;
  }

  .hero__image-wrapper img {
    width: 150px;
    height: 150px;
  }

  /* Plain block stacking on mobile — avoids grid track min-sizing blowout
     that would otherwise let long competition names overflow the viewport. */
  .experience-category {
    display: block;
    padding: var(--space-lg) 0;
  }

  .experience-category__title {
    margin-bottom: var(--space-sm);
  }

  /* Stack each competition row on narrow screens so the (often long) name
     gets the full width; rank/medal drop below, chevron pins to top-right. */
  .comp-row {
    position: relative;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding-right: 26px;
  }

  .comp-row::after {
    position: absolute;
    top: var(--space-md);
    right: 4px;
  }

  .comp-row__result {
    justify-content: flex-start;
  }

  .comp-row__name {
    font-size: 1rem;
  }

  .profile__item,
  .simple-list li,
  .news-item {
    grid-template-columns: 1fr;
    gap: var(--space-xxs);
  }

  .links__grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }

  html.js .reveal {
    opacity: 1;
    transform: none;
  }

  .modal {
    transition: opacity 0.001ms;
  }
}
