:root {
  --ivory: #EFE8DC;
  --walnut: #2A211C;
  --charcoal: #171719;
  --brass: #B59A6A;
  --terracotta: #B85C45;
  --dust: #968C82;

  --serif: 'Fraunces', serif;
  --hand: 'Caveat', cursive;
  --sans: 'Work Sans', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--charcoal);
  color: var(--ivory);
  font-family: var(--sans);
  overflow: hidden;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Cinematic vignette so the render doesn't feel flat/game-engine-default */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 45%, rgba(0,0,0,0.45) 100%);
}

/* ---------- Intro overlay ---------- */
#intro-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 1.8s ease;
}

#intro-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#intro-hint {
  font-family: var(--sans);
  font-weight: 300;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--dust);
  opacity: 0.7;
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.85; }
}

/* ---------- Name card ---------- */
#name-card {
  position: fixed;
  bottom: 12%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  font-family: var(--hand);
  font-size: 2.4rem;
  color: var(--ivory);
  opacity: 0;
  pointer-events: none;
  z-index: 50;
  transition: opacity 2s ease, transform 2s ease;
  text-shadow: 0 2px 12px rgba(0,0,0,0.5);
}

#name-card.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#name-card.faded {
  opacity: 0;
}

/* ---------- Nav ---------- */
#room-nav {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 60;
  font-family: var(--sans);
  opacity: 0;
  transition: opacity 1.5s ease;
}

#room-nav.visible { opacity: 1; }

.nav-toggle {
  background: rgba(23,23,25,0.55);
  border: 1px solid rgba(181,154,106,0.35);
  color: var(--brass);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.3s ease, color 0.3s ease;
}

.nav-toggle:hover {
  background: rgba(181,154,106,0.15);
  color: var(--ivory);
}

#nav-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 10px 4px;
  display: none;
  flex-direction: column;
  gap: 2px;
  background: rgba(23,23,25,0.75);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(181,154,106,0.2);
}

#nav-list.open { display: flex; }

#nav-list li {
  padding: 8px 18px;
  font-size: 0.85rem;
  color: var(--ivory);
  opacity: 0.8;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: opacity 0.2s ease, color 0.2s ease;
  text-align: right;
}

#nav-list li:hover {
  opacity: 1;
  color: var(--terracotta);
}

/* ---------- Interaction hint ---------- */
#hint-text {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--sans);
  font-weight: 300;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  color: var(--ivory);
  background: rgba(23,23,25,0.5);
  padding: 8px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 40;
  white-space: nowrap;
}

#hint-text.visible { opacity: 1; }

/* ---------- Panels ---------- */
.panel {
  position: fixed;
  top: 6%;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  width: min(680px, 88vw);
  max-height: 82vh;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(239,232,220,0.98), rgba(239,232,220,0.94));
  color: var(--walnut);
  border-radius: 18px;
  padding: 40px 44px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.panel h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 2rem;
  margin: 0 0 4px;
  color: var(--walnut);
}

.panel h2.handwritten {
  font-family: var(--hand);
  font-size: 2.6rem;
}

.panel-sub {
  color: var(--dust);
  font-size: 0.85rem;
  margin: 0 0 24px;
  letter-spacing: 0.02em;
}

.panel-close {
  position: absolute;
  top: 18px;
  right: 22px;
  background: none;
  border: none;
  font-size: 1.6rem;
  color: var(--dust);
  cursor: pointer;
  line-height: 1;
}

.panel-close:hover { color: var(--terracotta); }

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.project-card {
  background: rgba(42,33,28,0.05);
  border: 1px solid rgba(42,33,28,0.1);
  border-radius: 12px;
  padding: 16px 18px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.project-card:hover {
  background: rgba(184,92,69,0.08);
  border-color: rgba(184,92,69,0.3);
  transform: translateY(-2px);
}

.project-card h3 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--terracotta);
}

.project-card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--walnut);
  opacity: 0.8;
}

/* ---------- Project detail view ---------- */
#projects-grid.hidden { display: none; }

#project-detail {
  display: none;
}
#project-detail.visible { display: block; }

#project-back {
  background: none;
  border: none;
  color: var(--terracotta);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0 0 16px;
  letter-spacing: 0.02em;
}
#project-back:hover { opacity: 0.75; }

#project-detail-image {
  width: 100%;
  border-radius: 12px;
  display: block;
  margin-bottom: 20px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.18);
}

#project-detail-title {
  font-family: var(--serif);
  font-size: 1.6rem;
  margin: 0 0 10px;
  color: var(--walnut);
}

#project-detail-description {
  color: var(--walnut);
  opacity: 0.85;
  line-height: 1.55;
  margin: 0 0 20px;
}

#project-detail-links {
  display: flex;
  gap: 12px;
}

.notebook-pages h3.handwritten {
  font-family: var(--hand);
  font-size: 1.7rem;
  color: var(--terracotta);
  margin: 22px 0 6px;
}
.notebook-pages h3.handwritten:first-child { margin-top: 0; }

.notebook-pages p {
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--walnut);
  opacity: 0.88;
  margin: 0 0 4px;
}

/* Generic readable spacing for plain paragraphs inside panels (About, Future) */
.panel > p {
  line-height: 1.65;
  margin: 0 0 14px;
  opacity: 0.9;
}

.future-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.future-list li::before {
  content: '→ ';
  color: var(--terracotta);
}
.future-closing {
  font-family: var(--serif);
  font-style: italic;
  color: var(--terracotta);
  margin-top: 6px !important;
  opacity: 1 !important;
}

.skill-groups {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.skill-group h3 {
  margin: 0 0 4px;
  font-family: var(--serif);
  color: var(--terracotta);
}

.skill-group p {
  margin: 0;
  color: var(--walnut);
  opacity: 0.85;
}

.contact-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.95rem;
}

.contact-list a {
  color: var(--walnut);
  text-decoration: none;
  border-bottom: 1px solid rgba(184,92,69,0.35);
  padding-bottom: 2px;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.contact-list a:hover {
  color: var(--terracotta);
  border-color: var(--terracotta);
}

/* ---------- Contact form ---------- */
.hp-field {
  position: absolute;
  left: -9999px;
  top: -9999px;
}

.contact-form {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid rgba(42,33,28,0.12);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.contact-form label {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--dust);
  margin-top: 10px;
}

.contact-form input,
.contact-form textarea {
  font-family: var(--sans);
  font-size: 0.9rem;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(42,33,28,0.18);
  background: rgba(255,255,255,0.5);
  color: var(--walnut);
  resize: vertical;
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--terracotta);
}

.contact-form .resume-btn {
  align-self: flex-start;
  margin-top: 14px;
  border: none;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.85rem;
}

#contact-form-status {
  font-size: 0.82rem;
  margin: 8px 0 0;
  min-height: 1.1em;
}
#contact-form-status.success { color: #4f7a52; }
#contact-form-status.error { color: var(--terracotta); }

/* ---------- Resume panel ---------- */
.resume-actions {
  display: flex;
  gap: 14px;
  margin-top: 8px;
}

.resume-btn {
  display: inline-block;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  text-decoration: none;
  background: var(--terracotta);
  color: var(--ivory);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.resume-btn:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.resume-btn-outline {
  background: transparent;
  border: 1px solid var(--terracotta);
  color: var(--terracotta);
}

/* ---------- Quiet always-available resume link ---------- */
#resume-quick-link {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 60;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass);
  text-decoration: none;
  opacity: 0;
  transition: opacity 1.5s ease, color 0.2s ease;
  padding: 8px 4px;
}

#resume-quick-link.visible { opacity: 0.75; }
#resume-quick-link:hover { opacity: 1; color: var(--ivory); }

@media (max-width: 640px) {
  .panel { padding: 28px 24px; top: 4%; }
  #name-card { font-size: 1.8rem; }
}