:root {
  --bg: #141414;
  --text: #e8e4df;
  --text-muted: #a8a4a0;
  --name-text: #9a9692;
  --rule: #3a3a3a;
  --link-underline: #e8e4df;
  --placeholder-bg: #2a2a2a;
  --selection-bg: #fff;
  --selection-text: #141414;
  --content-max: 40rem;
  --content-pad: 1.5rem;
}

/* Light mode styles — feature disabled in script.js (no UI toggle). */
[data-theme="light"] {
  --bg: #f5f3f0;
  --text: #1a1a1a;
  --text-muted: #666;
  --name-text: #777;
  --rule: #ccc;
  --link-underline: #1a1a1a;
  --placeholder-bg: #ddd;
  --selection-bg: #1a1a1a;
  --selection-text: #fff;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s, color 0.2s;
}

a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

a:hover {
  opacity: 0.75;
}

::selection {
  background-color: var(--selection-bg);
  color: var(--selection-text);
}

::-moz-selection {
  background-color: var(--selection-bg);
  color: var(--selection-text);
}

/* Header */

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2.5rem var(--content-pad) 0;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

.site-name {
  font-family: inherit;
  font-size: 1.625rem;
  font-weight: inherit;
  text-decoration: none;
  color: #fff;
}

[data-theme="light"] .site-name {
  color: var(--text);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9375rem;
  color: var(--name-text);
}

.site-nav a {
  text-transform: lowercase;
  color: inherit;
  text-decoration: none;
}

.nav-sep {
  color: inherit;
  user-select: none;
}

/* Main */

main {
  flex: 1;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  padding: 3rem var(--content-pad) 4rem;
}

.main-views {
  display: block;
}

.page-view {
  display: none;
}

.page-view.is-active {
  display: block;
  animation: page-fade-in 0.2s ease;
}

@keyframes page-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .page-view.is-active {
    animation: none;
  }
}

.section {
  margin-bottom: 4rem;
  scroll-margin-top: 2rem;
}

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

.section-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.section-rule {
  border: none;
  border-top: 1px solid var(--rule);
  margin-bottom: 2rem;
}

/* About */

.about-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2rem;
  align-items: start;
}

.about-text p {
  font-size: 0.9375rem;
  margin-bottom: 1.75rem;
}

.about-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
}

.about-links a {
  text-transform: lowercase;
}

.email-copy-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 0.25rem;
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  cursor: pointer;
  vertical-align: middle;
  line-height: 0;
}

.email-copy-btn svg {
  display: block;
  width: 15px;
  height: 15px;
}

.email-copy-btn:hover svg {
  opacity: 0.75;
}

.email-copy-btn.is-copied::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text);
}

.email-copy-btn.is-copied::after {
  content: "copied!";
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.8125rem;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  pointer-events: none;
  animation: copy-tooltip-in 0.15s ease forwards;
}

.email-copy-btn.is-copied.is-leaving::before,
.email-copy-btn.is-copied.is-leaving::after {
  animation: copy-tooltip-out 0.15s ease forwards;
}

@keyframes copy-tooltip-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes copy-tooltip-out {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(4px);
  }
}

.link-sep {
  color: var(--text-muted);
  user-select: none;
}

.social-icon {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  text-decoration: none;
  text-transform: none;
  line-height: 0;
}

.social-icon svg {
  display: block;
}

.about-photo {
  flex-shrink: 0;
}

.photo-placeholder {
  width: 120px;
  height: 120px;
  border: none;
  border-radius: 50%;
  background-color: var(--placeholder-bg);
  cursor: pointer;
  padding: 0;
  transition: background-color 0.2s;
}

.photo-placeholder:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 4px;
}

.page-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  min-height: 100vh;
}

/* Rainbow text flush */

.rainbow-char {
  display: inline;
}

.page-shell.is-rainbow-flush .rainbow-char,
.page-shell.is-rainbow-flush .rainbow-unit {
  animation: rainbow-text-cycle var(--rainbow-pulse, 1.05s) cubic-bezier(0.42, 0, 0.18, 1) both;
  animation-delay: var(--rainbow-delay, 0s);
}

.page-shell.is-rainbow-flush .about-links a {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--link-underline);
}

.page-shell.is-rainbow-flush .site-nav a {
  text-decoration: none;
}

.page-shell.is-rainbow-flush .footer-time {
  text-decoration: none;
}

@keyframes rainbow-text-cycle {
  0%,
  100% {
    color: inherit;
    text-shadow: none;
    filter: none;
  }
  10% {
    color: #ffffff;
    text-shadow:
      0 0 8px #ff1744,
      0 0 16px #00e5ff,
      0 0 2px rgba(0, 0, 0, 0.8);
    filter: saturate(1.8) contrast(1.25);
  }
  22% {
    color: #fff500;
    text-shadow:
      0 0 8px #ff6d00,
      0 0 16px #ff0080;
    filter: saturate(2) contrast(1.3);
  }
  35% {
    color: #00ffaa;
    text-shadow:
      0 0 8px #00aaff,
      0 0 16px #7700ff;
    filter: saturate(2.1) contrast(1.35);
  }
  48% {
    color: #00eeff;
    text-shadow:
      0 0 8px #0055ff,
      0 0 16px #ff00aa;
    filter: saturate(2) contrast(1.3);
  }
  62% {
    color: #dd88ff;
    text-shadow:
      0 0 8px #aa00ff,
      0 0 16px #00ff88;
    filter: saturate(2.1) contrast(1.35);
  }
  75% {
    color: #ff66dd;
    text-shadow:
      0 0 8px #ff0066,
      0 0 16px #ffee00;
    filter: saturate(1.9) contrast(1.3);
  }
  88% {
    color: #ff4466;
    text-shadow:
      0 0 10px #44ffff,
      0 0 22px #ffff44,
      0 0 4px rgba(0, 0, 0, 0.6);
    filter: saturate(2.2) contrast(1.4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .page-shell.is-rainbow-flush .rainbow-char,
  .page-shell.is-rainbow-flush .rainbow-unit {
    animation-duration: var(--rainbow-pulse, 0.55s);
    animation-timing-function: ease-in-out;
  }

  @keyframes rainbow-text-cycle {
    0%,
    100% {
      color: inherit;
      text-shadow: none;
      filter: none;
    }
    50% {
      color: #ffffff;
      text-shadow: 0 0 8px #00ccff, 0 0 14px #ff3366;
      filter: saturate(1.5) contrast(1.2);
    }
  }
}

/* Entries (education, experience, etc.) */

.entry {
  margin-bottom: 1.75rem;
}

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

.entry-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.entry-org {
  font-size: 0.9375rem;
  font-weight: 600;
}

.entry-date {
  font-size: 0.875rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.entry-detail {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Footer */

.site-footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 2rem var(--content-pad) 2.5rem;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.footer-updated {
  justify-self: start;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.footer-time {
  justify-self: center;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.footer-hand {
  justify-self: end;
  display: inline-flex;
  align-items: center;
}

.hand-btn {
  background: none;
  border: none;
  padding: 0.35rem 0.25rem;
  cursor: pointer;
  line-height: 1;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.hand-cards {
  display: inline-flex;
  align-items: center;
}

.playing-card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 36px;
  padding: 2px;
  border: 1.5px solid #4a4a4a;
  border-radius: 3px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.625rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  gap: 1px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
}

.playing-card + .playing-card {
  margin-left: -8px;
  transform: rotate(5deg);
}

.playing-card[data-suit="hearts"],
.playing-card[data-suit="diamonds"] {
  color: #c96a6a;
  border-color: #6e4545;
}

.playing-card[data-rank="10"] .card-rank {
  font-size: 0.5rem;
  letter-spacing: -0.04em;
}

.card-suit {
  font-size: 0.6875rem;
  line-height: 1;
}

.hand-btn:hover .playing-card,
.hand-btn:focus-visible .playing-card {
  border-color: var(--text-muted);
}

.hand-btn:focus-visible {
  outline: 2px solid var(--text-muted);
  outline-offset: 3px;
  border-radius: 4px;
}

.hand-cards.is-dealing .playing-card {
  animation: card-deal 0.38s cubic-bezier(0.22, 0.61, 0.36, 1) backwards;
}

.hand-cards.is-dealing .playing-card:nth-child(2) {
  animation-delay: 0.09s;
}

@keyframes card-deal {
  0% {
    opacity: 0;
    transform: translateY(-12px) rotate(-10deg) scale(0.88);
  }
  100% {
    opacity: 1;
    transform: translateY(0) rotate(var(--card-tilt, 0deg)) scale(1);
  }
}

.hand-cards.is-dealing .playing-card:nth-child(1) {
  --card-tilt: 0deg;
}

.hand-cards.is-dealing .playing-card:nth-child(2) {
  --card-tilt: 5deg;
}

@media (prefers-reduced-motion: reduce) {
  .hand-cards.is-dealing .playing-card {
    animation: none;
  }
}

/* Responsive */

@media (max-width: 640px) {
  .site-header {
    flex-direction: column;
    gap: 1.25rem;
    padding: 2rem var(--content-pad) 0;
  }

  .site-nav {
    flex-wrap: wrap;
  }

  main {
    padding: 2.5rem var(--content-pad) 3rem;
  }

  .about-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .about-photo {
    display: none;
  }

  .site-footer {
    display: none;
  }
}
