/* =========================================================================
   Kálai Előd Alex — Portfólió (könyv nézet)
   Dark, immersive, shader-backed book experience
   ========================================================================= */

:root {
  --ink:      #ece7dd;   /* light text */
  --muted:    #9a948a;
  --faint:    #6f6a60;
  --line:     rgba(236, 231, 221, 0.16);
  --line-2:   rgba(236, 231, 221, 0.10);
  --accent:   #cf9670;   /* warm brushed-bronze highlight */
  --bg-base:  #0d0c0a;
  --paper:    #ffffff;

  --font-display: 'Jost', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;

  --menu-h: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: dark;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ----------------------- Shader background + veil ----------------------- */
#bg {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; display: block;
  /* CSS fallback if WebGL fails */
  background:
    radial-gradient(120% 90% at 50% -10%, #26231d 0%, #131210 55%, #0b0a08 100%);
}
#veil {
  position: fixed; inset: 0; z-index: 1;
  background: #0b0a08;
  opacity: 0;
  transition: opacity 0.8s var(--ease);
  pointer-events: none;
}
body.is-loading             #veil { opacity: 0; }
body[data-view="book"]:not(.is-loading)    #veil { opacity: 0.76; }
body[data-view="contact"]:not(.is-loading) #veil { opacity: 0.55; }

/* ----------------------------- Menu ----------------------------- */
.menu {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: var(--menu-h);
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 clamp(1.2rem, 4vw, 3rem);
  opacity: 0; transform: translateY(-6px);
  transition: opacity 0.6s var(--ease) 0.15s, transform 0.6s var(--ease) 0.15s;
  pointer-events: none;
}
body:not(.is-loading) .menu { opacity: 1; transform: none; pointer-events: auto; }

.menu__nav { display: flex; gap: clamp(1.2rem, 3vw, 2.4rem); }
.menu__tab {
  font-family: var(--font-display); font-size: 0.98rem; letter-spacing: 0.04em;
  color: var(--muted); padding: 0.5rem 0.1rem; position: relative;
  transition: color 0.28s var(--ease);
}
.menu__tab::after {
  content: ""; position: absolute; left: 0; right: 100%; bottom: -2px; height: 1px;
  background: var(--ink); transition: right 0.32s var(--ease);
}
.menu__tab:hover { color: var(--ink); }
.menu__tab.is-active { color: var(--ink); }
.menu__tab.is-active::after { right: 0; }

/* ----------------------------- Views ----------------------------- */
main { position: fixed; inset: 0; z-index: 10; }
.view {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden;
  transition: opacity 0.6s var(--ease), visibility 0.6s var(--ease);
}
.view.is-active { opacity: 1; visibility: visible; }
.view[hidden] { display: none; }
/* While loading, only the shader + loader are visible */
body.is-loading .view { opacity: 0 !important; visibility: hidden !important; }

/* ----------------------------- Book ----------------------------- */
.view--book { padding-top: var(--menu-h); }
.stage {
  flex: 1; min-height: 0;
  display: grid; place-items: center;
  padding: clamp(0.6rem, 2.4vh, 1.8rem) clamp(0.8rem, 3vw, 2.4rem);
}
.book { filter: drop-shadow(0 40px 90px rgba(0,0,0,0.65)); }
.book .page { background: var(--paper); overflow: hidden; }
.book .page img { width: 100%; height: 100%; object-fit: fill; display: block; }
.book .page--hard { background: #f3efe8; }

/* Book controls */
.book-ui {
  display: flex; align-items: center; justify-content: center; gap: clamp(0.6rem, 2vw, 1.2rem);
  padding: 0.4rem 0 0.2rem;
}
.book-ui__btn {
  width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%;
  color: var(--ink); border: 1px solid var(--line);
  transition: border-color 0.25s var(--ease), background-color 0.25s var(--ease), transform 0.18s var(--ease);
}
.book-ui__btn svg { width: 20px; height: 20px; }
.book-ui__btn:hover { border-color: rgba(236,231,221,0.5); background: rgba(236,231,221,0.06); }
.book-ui__btn:active { transform: scale(0.93); }
.book-ui__fs { margin-left: 0.2rem; }

.book-hint {
  text-align: center; font-family: var(--font-display);
  font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--faint); padding: 0.6rem 1rem max(0.8rem, env(safe-area-inset-bottom));
  transition: opacity 0.5s var(--ease);
}
.book-hint.is-gone { opacity: 0; }

/* ----------------------------- Contact ----------------------------- */
.view--contact { align-items: center; justify-content: center; padding: var(--menu-h) 1.25rem 2rem; }
.contact {
  width: 100%; max-width: 540px; text-align: center;
  background: rgba(18, 16, 13, 0.5);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: clamp(2.2rem, 6vw, 4rem) clamp(1.5rem, 5vw, 3.4rem);
  backdrop-filter: blur(22px) saturate(120%);
  -webkit-backdrop-filter: blur(22px) saturate(120%);
  box-shadow: 0 40px 90px -50px rgba(0,0,0,0.8);
}
.contact__eyebrow {
  font-family: var(--font-display); font-size: 0.74rem; letter-spacing: 0.24em;
  text-transform: uppercase; color: var(--accent);
}
.contact__title {
  font-family: var(--font-display); font-weight: 300; letter-spacing: -0.01em;
  font-size: clamp(2rem, 6vw, 3.1rem); line-height: 1.05; margin: 0.9rem 0 0.7rem;
}
.contact__lead { color: var(--muted); font-size: 1.02rem; max-width: 36ch; margin: 0 auto; }

.contact__form { margin-top: 2.2rem; }
.field {
  display: flex; align-items: center; gap: 0.6rem;
  border-bottom: 1px solid var(--line);
  padding: 0.5rem 0.2rem;
  transition: border-color 0.3s var(--ease);
}
.field:focus-within { border-color: var(--accent); }
.field input {
  flex: 1; min-width: 0; background: transparent; border: none; color: var(--ink);
  font-family: var(--font-body); font-size: 1.06rem; padding: 0.55rem 0.2rem; min-height: 44px;
}
.field input::placeholder { color: var(--faint); }
.field input:focus { outline: none; }
.field__submit {
  width: 46px; height: 46px; flex: none; border-radius: 50%;
  display: grid; place-items: center; color: var(--bg-base); background: var(--ink);
  transition: background-color 0.25s var(--ease), transform 0.2s var(--ease);
}
.field__submit svg { width: 20px; height: 20px; }
.field__submit:hover { background: var(--accent); }
.field__submit:active { transform: scale(0.93); }
.field__submit:disabled { opacity: 0.5; pointer-events: none; }

.contact__error { color: #e0876b; font-size: 0.88rem; margin-top: 0.9rem; text-align: left; }
.contact__alt { margin-top: 1.8rem; color: var(--faint); font-size: 0.9rem; }
.contact__alt a {
  color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 1px;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.contact__alt a:hover { color: var(--ink); border-color: var(--accent); }

.contact__success { margin-top: 1.6rem; }
.contact__success-title { font-family: var(--font-display); font-size: 1.6rem; font-weight: 400; color: var(--accent); }
.contact__success-text { color: var(--muted); margin-top: 0.4rem; }

/* ----------------------------- Loader ----------------------------- */
.loader {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center;
  opacity: 1; transition: opacity 0.8s var(--ease), visibility 0.8s;
}
.loader.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader__inner { text-align: center; padding: 2rem; }
.loader__name {
  font-family: var(--font-display); font-size: 0.78rem; letter-spacing: 0.34em;
  text-transform: uppercase; color: var(--muted);
}
.loader__word {
  font-family: var(--font-display); font-weight: 300;
  font-size: clamp(2.4rem, 8vw, 4.2rem); letter-spacing: -0.01em; color: var(--ink);
  margin: 0.6rem 0 1.8rem;
}
.loader__bar {
  width: min(260px, 60vw); height: 1px; margin: 0 auto;
  background: rgba(236, 231, 221, 0.16); overflow: hidden; position: relative;
}
.loader__fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--ink));
  transition: width 0.3s var(--ease);
}
.loader__pct {
  font-family: var(--font-display); font-size: 0.78rem; letter-spacing: 0.16em;
  color: var(--faint); margin-top: 1rem; font-variant-numeric: tabular-nums;
}

/* ----------------------------- Responsive ----------------------------- */
@media (max-width: 640px) {
  .book-hint { font-size: 0.64rem; letter-spacing: 0.14em; }
  .book-ui__btn { width: 42px; height: 42px; }
  .menu__tab { font-size: 0.92rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.001ms !important; animation: none !important; }
}
