/* ==============================================
   Espada Software — Nier-inspired design
   ============================================== */

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

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400&display=swap');

:root {
  --bg: #0b0b0c;
  --panel: rgba(18, 18, 20, 0.88);
  --text: #c8c0b4;
  --text-dim: #6b6760;
  --text-bright: #e8e0d4;
  --accent: #9b8c78;
  --accent-dim: rgba(155, 140, 120, 0.15);
  --border: rgba(180, 170, 150, 0.12);
  --border-strong: rgba(180, 170, 150, 0.25);
  --radius: 1px;
  --font-heading: 'Cormorant Garamond', 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --gap: clamp(20px, 4vw, 48px);
  --pad: clamp(24px, 5vw, 56px);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; transition: color 0.3s; }
a:hover { color: var(--text-bright); }

/* --- Hero canvas (top of page, in normal document flow) --- */
.hero { position: relative; }

.hero::after { /* fade hero into page bg */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 120px;
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none;
}

#c {
  display: block;  /* kills inline gap */
  width: 100%;
  height: 8vh;    /* hero height */
  min-height: 210px;
}

/* --- Loading screen — page stays hidden until the scene has rendered --- */
#loader {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  opacity: 1; visibility: visible;
  transition: opacity 0.9s ease, visibility 0s linear 0.9s;
}

#loader.done { opacity: 0; visibility: hidden; }

#loader .loader-text {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: clamp(15px, 2.5vw, 19px);
  letter-spacing: 0.25em;
  color: var(--text-dim);
  animation: loaderBreathe 2.6s ease-in-out infinite;
}

#loader .loader-text span {
  display: inline-block;
  animation: loaderDot 2.6s ease-in-out infinite;
}

#loader .loader-text span + span { animation-delay: 0.45s; }

@keyframes loaderBreathe {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 1; }
}

@keyframes loaderDot {
  0%, 25%, 100% { opacity: 0.2; transform: translateY(0); }
  45%           { opacity: 1;   transform: translateY(-1px); }
}

/* Hero + content fade in together as the loader fades out (body.ready set by app.js) */
.hero, #overlay {
  opacity: 0;
  transition: opacity 1s ease;
}

body.ready .hero, body.ready #overlay { opacity: 1; }

/* --- Overlay container --- */
#overlay {
  display: flex; flex-direction: column;
  align-items: center;
  padding: var(--gap);
}

/* --- Header area --- */
header {
  text-align: center;
  width: 100%;
  max-width: 860px;
  margin-bottom: var(--gap);
}

header .logo-wordmark {
  font-family: var(--font-heading);
  font-size: clamp(28px, 6vw, 56px);
  font-weight: 500;
  letter-spacing: 0.15em;
  color: var(--text-bright);
  text-transform: uppercase;
}

header .tagline {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: clamp(13px, 2vw, 17px);
  color: var(--text-dim);
  letter-spacing: 0.08em;
  margin-top: 4px;
}

header .rule {
  width: 120px; height: 1px;
  background: var(--border-strong);
  margin: 20px auto;
}

/* --- Nav --- */
nav {
  display: flex; gap: 4px;
  margin-bottom: var(--gap);
  width: 100%; max-width: 860px;
}

nav button {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-heading);
  font-size: clamp(13px, 2.2vw, 17px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 14px 8px;
  transition: color 0.4s, border-color 0.4s;
}

nav button:hover { color: var(--text-bright); }
nav button.active {
  color: var(--text-bright);
  border-bottom-color: var(--text-bright);
}

/* --- Content panels --- */
section {
  display: none;
  width: 100%; max-width: 860px;
}

section.active {
  display: block;
  animation: fadeUp 0.6s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Panel card (shared) --- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: var(--pad);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* --- Home --- */
#home .panel {
  text-align: center;
  padding: clamp(40px, 8vw, 80px) var(--pad);
}

#home .panel img {
  width: clamp(140px, 25vw, 220px);
  opacity: 0.9;
}

#home .panel .subtitle {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: 15px;
  color: var(--text-dim);
  margin-top: 16px;
}

/* --- Projects --- */
#projects {
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

#projects.active { display: grid; }

#projects .panel {
  display: flex; gap: 16px; align-items: flex-start;
  transition: border-color 0.3s;
}

#projects .panel:hover { border-color: var(--border-strong); }

#projects .panel .glyph {
  width: 52px; height: 52px; flex-shrink: 0;
  opacity: 0.85;
}

#projects .panel .glyph img,
#projects .panel .glyph svg {
  width: 100%; height: 100%;
}

#projects .panel h3 {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--text-bright);
}

#projects .panel .kind {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-bottom: 6px;
}

#projects .panel p {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

#projects .panel .link {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 6px 20px;
  transition: background 0.3s, color 0.3s;
}

#projects .panel .link:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-bright);
}

#projects .panel .link.disabled {
  color: var(--text-dim);
  border-color: var(--border);
  pointer-events: none;
}

/* --- Services --- */
#services {
  display: none; gap: 1px; background: var(--border);
}

#services.active { display: flex; flex-direction: column; }

#services .panel {
  display: flex; gap: 20px; align-items: center;
  border: none;
}

#services .panel + .panel { border-top: 1px solid var(--border); }

#services .panel .glyph {
  width: 64px; height: 64px; flex-shrink: 0;
}

#services .panel .glyph img {
  width: 100%; height: 100%; opacity: 0.8;
}

#services .panel h3 {
  font-family: var(--font-heading);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-bright);
}

#services .panel p {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* --- Contact --- */
#contact .panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}

#contact .panel .info {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 2;
}

#contact .panel .info a {
  color: var(--text);
}

#contact .panel .info .rule {
  width: 40px; height: 1px;
  background: var(--border-strong);
  margin: 12px 0;
}

#contact label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin: 16px 0 6px;
}

#contact input,
#contact textarea {
  display: block; width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit; font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.3s;
}

#contact input:focus,
#contact textarea:focus {
  border-color: var(--border-strong);
}

#contact textarea { resize: vertical; min-height: 120px; }

#contact button {
  margin-top: 16px;
  padding: 10px 36px;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
  font-family: var(--font-heading);
  font-size: 15px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.3s, color 0.3s, border-color 0.3s;
}

#contact button:hover:not(:disabled) {
  background: rgba(255,255,255,0.06);
  color: var(--text-bright);
  border-color: var(--border-strong);
}

#contact button:disabled { opacity: 0.25; cursor: default; }

#contact .msg {
  margin-top: 12px;
  font-size: 13px;
  color: var(--accent);
  font-style: italic;
  display: none;
}

#contact .msg.show { display: block; }

/* --- Footer --- */
.site-footer {
  margin-top: var(--gap);
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}

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

.site-footer span { margin: 0 8px; opacity: 0.3; }

/* --- Mobile --- */
@media (max-width: 640px) {
  #overlay { padding: 16px; }

  nav {
    flex-wrap: wrap; gap: 2px;
  }

  nav button {
    flex: 1 1 45%;
    font-size: 13px; padding: 10px 4px;
  }

  #projects.active { grid-template-columns: 1fr; }

  #contact .panel {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  #services .panel { flex-direction: column; text-align: center; }
}

/* --- Legal pages --- */
.legal {
  max-width: 740px;
  margin: 0 auto;
  padding: 48px 24px;
  font-family: var(--font-body);
}

.legal h1 {
  font-family: var(--font-heading);
  font-size: clamp(24px, 5vw, 40px);
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-bright);
}

.legal h2 {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 500;
  color: var(--text-bright);
  margin: 32px 0 8px;
  letter-spacing: 0.04em;
}

.legal p, .legal li {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.legal .meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 0;
}

.legal ul { padding-left: 20px; margin-bottom: 12px; }

.legal hr {
  border: none; border-top: 1px solid var(--border);
  margin: 24px 0;
}

.legal .box {
  background: rgba(180, 140, 100, 0.06);
  border: 1px solid rgba(180, 140, 100, 0.15);
  padding: 20px;
  margin-bottom: 28px;
}

.legal .box strong { color: var(--accent); }

.legal a { color: var(--accent); }

.legal .btn {
  display: inline-block;
  padding: 10px 24px;
  background: transparent;
  color: #d88;
  border: 1px solid rgba(220, 100, 100, 0.3);
  font-family: var(--font-heading);
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background 0.3s, border-color 0.3s;
}

.legal .btn:hover {
  background: rgba(220, 100, 100, 0.08);
  border-color: rgba(220, 100, 100, 0.5);
  color: #faa;
}
