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

/* Tokens */
:root {
  --bg: #F4EBDE;
  --surface: #FFFCF9;
  --text: #111;
  --text-muted: #5a5a5a;
  --text-subtle: #999;
  --accent: #D94F43;
  --border: #E4D9CD;
  --header-bg: rgba(244, 235, 222, 0.9);
  --radius: 12px;
  --font: "Inter", system-ui, sans-serif;
  --max-w: 900px;
  --shadow: 0 2px 8px rgba(0,0,0,0.07);
}

[data-theme="dark"] {
  --bg: #1c1a17;
  --surface: #26231f;
  --text: #f3ead9;
  --text-muted: #a89e8e;
  --text-subtle: #6f6960;
  --border: #3a3530;
  --header-bg: rgba(28, 26, 23, 0.85);
  --shadow: 0 2px 8px rgba(0,0,0,0.35);
}

/* Base */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Background rotating shape */
.bg-shape {
  position: fixed;
  width: 764px;
  height: 771px;
  bottom: 10%;
  right: -10%;
  background: url('imgs/detail/wave.png') center center no-repeat;
  background-size: contain;
  animation: rotate-shape 90s linear infinite;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
}

@keyframes rotate-shape {
  from { transform: rotate(145deg); }
  to   { transform: rotate(865deg); }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #1a1a1a;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.site-name {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
}

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

.nav-link--resume {
  color: var(--accent);
  border: 1.5px solid var(--accent) !important;
  margin-left: 10px;
  padding: 5px 14px;
}

.nav-link--resume:hover {
  background: var(--accent);
  color: #fff;
}

/* Main */
main {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 56px 40px 80px;
  display: flex;
  flex-direction: column;
  gap: 48px;
  position: relative;
  z-index: 1;
}

/* Hero */
.hero {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 52px;
}

.hero-photo-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.hero-photo-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  mix-blend-mode: multiply;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

[data-theme="dark"] .hero-photo-wrap::after {
  opacity: 0.35;
}

.hero-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 35%;
  display: block;
}

.hero-text {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero-edu {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
}

.hero-name {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.hero-role {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-muted);
}

.hero-blurb {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.75;
  max-width: 500px;
}

/* Sections */
.section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-subtle);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* Project grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

/* Project card */
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.project-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.09);
}

.project-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.project-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.project-link {
  display: block;
  min-width: 0;
}

.project-meta {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-subtle);
}

.project-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
}

.project-link:hover .project-name {
  text-decoration: underline;
}

.project-logo {
  max-width: 80px;
  max-height: 32px;
  width: auto;
  height: auto;
  flex-shrink: 0;
  opacity: 0.75;
  transition: filter 0.3s ease;
}

[data-theme="dark"] .project-logo {
  filter: invert(0.7);
}

[data-theme="dark"] .site-name,
[data-theme="dark"] .hero-name {
  color: var(--text-muted);
}

.project-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.tag {
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  color: var(--text-subtle);
}

/* Floating settings cluster */
.settings {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.settings-toggle,
.settings-action {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-family: var(--font);
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.25s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

.settings-toggle:hover,
.settings-action:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.settings-toggle .icon,
.settings-action .icon {
  width: 18px;
  height: 18px;
}

.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  transform: translateY(8px) scale(0.95);
  pointer-events: none;
  transform-origin: bottom center;
  transition: opacity 0.2s ease, transform 0.2s ease;
  order: -1;
}

.settings[data-open="true"] .settings-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.settings[data-open="true"] .settings-toggle {
  transform: rotate(60deg);
  color: var(--accent);
  border-color: var(--accent);
}

.icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: block; }

[data-theme="dark"] .bg-shape {
  opacity: 0.18;
  filter: invert(1) brightness(0.9);
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 20px;
  font-size: 0.8rem;
  color: var(--text-subtle);
  position: relative;
  z-index: 1;
}

/* Responsive */
@media (max-width: 640px) {
  .site-header { padding: 0 20px; }
  main { padding: 36px 20px 60px; gap: 40px; }
  .hero { grid-template-columns: 1fr; gap: 28px; }
  .hero-photo-wrap { width: 200px; aspect-ratio: 4 / 5; }
  .hero-name { font-size: 1.8rem; }
  .hero-blurb { max-width: 100%; }
  .site-nav { gap: 0; }
  .bg-shape { width: 400px; height: 400px; right: -20%; bottom: 5%; }
  .toast { white-space: normal; text-align: center; width: calc(100% - 40px); }
}
