/* ============================================================
   WERHINO 2.0 - Free-account gate + auth modal
   Public landing; functionality unlocks after a free account.
   Layers on platform.css tokens.
   ============================================================ */

/* ---------- gate overlay (wraps a tool, e.g. the explorer) ---------- */
[data-gate] { position: relative; }
.gate { display: none; }
body:not(.is-member) [data-gate] > .gate {
  display: flex; align-items: center; justify-content: center;
  position: absolute; inset: 0; z-index: 6; padding: 1.5rem;
}
body:not(.is-member) [data-gate] > :not(.gate) {
  filter: blur(7px) saturate(.85); pointer-events: none; user-select: none; opacity: .6;
  transition: filter .5s var(--ease);
}
.gate__card {
  max-width: 440px; text-align: center;
  background: var(--bg-glass); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid var(--line-2); border-radius: 20px;
  padding: clamp(2rem, 3vw, 2.8rem); box-shadow: 0 36px 90px rgba(0,0,0,.55);
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
}
.gate__lock { width: 50px; height: 50px; color: var(--accent); border: 1px solid var(--line-2); border-radius: 50%; display: grid; place-items: center; }
.gate__lock svg { width: 24px; height: 24px; }
.gate__card h3 { font-family: var(--font-d); font-weight: 500; font-size: clamp(1.5rem,2.4vw,2rem); line-height: 1.05; }
.gate__card p { color: var(--muted); font-size: .92rem; line-height: 1.6; max-width: 34ch; }
.gate__link { font-size: .74rem; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; transition: color .3s; }
.gate__link:hover { color: var(--accent); }

/* ---------- full-page guard (members-only tool pages) ---------- */
body.is-gated { overflow: hidden; }
.guard { display: none; position: fixed; inset: 0; z-index: 350; }
.guard.is-open { display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.guard__backdrop {
  position: absolute; inset: 0; background: rgba(6,5,4,.74);
  -webkit-backdrop-filter: blur(16px) saturate(.9); backdrop-filter: blur(16px) saturate(.9);
  animation: authFade .4s var(--ease);
}
.guard__card {
  position: relative; width: min(520px, 100%); text-align: center;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 22px;
  padding: clamp(2rem, 3.4vw, 3rem); box-shadow: 0 50px 130px rgba(0,0,0,.6);
  animation: authPop .55s var(--ease);
}
.guard__lock {
  width: 54px; height: 54px; margin: 0 auto; border-radius: 50%;
  border: 1px solid var(--line-2); color: var(--accent); display: grid; place-items: center;
}
.guard__lock svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.guard__eyebrow { display: block; margin-top: 1.1rem; font-size: .64rem; font-weight: 600; letter-spacing: .26em; text-transform: uppercase; color: var(--accent); }
.guard__title { font-family: var(--font-d); font-weight: 500; font-size: clamp(1.7rem, 3vw, 2.4rem); line-height: 1.06; margin: .55rem 0 .7rem; }
.guard__title em { font-style: italic; color: var(--accent); }
.guard__sub { color: var(--muted); font-size: .92rem; line-height: 1.65; max-width: 42ch; margin: 0 auto 1.3rem; }
.guard__list { list-style: none; text-align: left; max-width: 350px; margin: 0 auto 1.6rem; display: grid; gap: .6rem; padding: 0; }
.guard__list li { position: relative; padding-left: 1.8rem; font-size: .88rem; color: var(--text); }
.guard__list li::before {
  content: ""; position: absolute; left: 0; top: .05rem; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent-dim);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23C9A86A' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13l4 4L19 7'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center;
}
.guard__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .8rem; }
.guard__back { display: inline-block; margin-top: 1.2rem; font-size: .74rem; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; transition: color .3s; }
.guard__back:hover { color: var(--accent); }

/* ---------- auth modal ---------- */
.auth { position: fixed; inset: 0; z-index: 400; display: none; align-items: center; justify-content: center; padding: 1.2rem; }
.auth.is-open { display: flex; }
.auth__backdrop { position: absolute; inset: 0; background: rgba(6,5,4,.82); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.auth.is-open .auth__backdrop { animation: authFade .35s var(--ease); }
@keyframes authFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes authPop { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
.auth__card {
  position: relative; width: min(560px, 100%); max-height: 92vh; overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 20px;
  padding: clamp(1.7rem, 3vw, 2.7rem);
  box-shadow: 0 50px 130px rgba(0,0,0,.6);
}
.auth.is-open .auth__card { animation: authPop .5s var(--ease); }
.auth__close {
  position: absolute; top: 1rem; right: 1rem; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: var(--muted); border: 1px solid var(--line);
  transition: background .3s, color .3s, transform .3s var(--ease);
}
.auth__close:hover { background: var(--accent); color: #1a1409; transform: rotate(90deg); }
.auth__close svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.auth__eyebrow { font-size: .64rem; font-weight: 600; letter-spacing: .26em; text-transform: uppercase; color: var(--accent); }
.auth__title { font-family: var(--font-d); font-weight: 500; font-size: clamp(1.9rem, 3.4vw, 2.6rem); line-height: 1.04; margin: .7rem 0 .5rem; }
.auth__title em { font-style: italic; color: var(--accent); }
.auth__sub { color: var(--muted); font-size: .92rem; line-height: 1.6; margin-bottom: 1.6rem; }

.field { display: flex; flex-direction: column; gap: .42rem; margin-bottom: .95rem; }
.field--row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.field--row .field { margin-bottom: 0; }
.field > label { font-size: .64rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.field input, .field select {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-input);
  padding: .85em 1em; color: var(--text); font: inherit; font-size: .92rem;
  transition: border-color .3s; appearance: none; -webkit-appearance: none;
}
.field input::placeholder { color: rgba(244,239,231,.42); }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23A39B8B' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 1em center; padding-right: 2.4em; }
.field__err { font-size: .72rem; color: #cf6f57; min-height: 1em; }

.auth__submit { width: 100%; margin-top: .5rem; }
.auth__alt { margin-top: 1.2rem; font-size: .84rem; color: var(--muted); text-align: center; }
.auth__alt button { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.auth__fine { margin-top: 1rem; font-size: .72rem; color: var(--faint); text-align: center; line-height: 1.5; }
.auth [data-mode-login] { display: none; }
.auth.mode-login [data-mode-register] { display: none; }
.auth.mode-login [data-mode-login] { display: block; }

/* ---------- member nav (logged in) ---------- */
body.is-member .nav__cta { display: none; }
body.is-member #navLogin { display: none; }

.nav__acct { display: none; position: relative; }
body.is-member .nav__acct { display: inline-flex; }
.nav__acct-btn {
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .4em .8em .4em .45em; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
  font: inherit; font-size: .78rem; cursor: pointer; transition: border-color .3s, background .3s;
}
.nav__acct-btn:hover { border-color: var(--accent); }
.nav__acct-av {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: var(--accent); color: #1a1409; font-family: var(--font-d); font-weight: 600; font-size: .9rem; line-height: 1;
}
.nav__acct-name { font-weight: 500; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav__acct-cv { width: 13px; height: 13px; stroke: var(--muted); fill: none; stroke-width: 1.8; transition: transform .3s var(--ease); }
.nav__acct.is-open .nav__acct-cv { transform: rotate(180deg); }

.nav__acct-menu {
  position: absolute; top: calc(100% + 12px); right: 0; width: 264px;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,.55); padding: .5rem;
  opacity: 0; visibility: hidden; transform: translateY(-8px);
  transition: opacity .25s var(--ease), transform .25s var(--ease), visibility .25s; z-index: 60;
}
.nav__acct.is-open .nav__acct-menu { opacity: 1; visibility: visible; transform: none; }
.nav__acct-head { display: flex; align-items: center; gap: .7rem; padding: .7rem .7rem .9rem; border-bottom: 1px solid var(--line); margin-bottom: .4rem; }
.nav__acct-head .nav__acct-av { width: 38px; height: 38px; font-size: 1.2rem; }
.nav__acct-id { min-width: 0; }
.nav__acct-id b { display: block; font-weight: 600; font-size: .9rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav__acct-id span { display: block; font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav__acct-menu a, .nav__acct-out {
  display: flex; align-items: center; gap: .65rem; width: 100%;
  padding: .62em .7em; border-radius: 9px; font-size: .82rem; color: var(--text);
  background: none; border: 0; text-align: left; cursor: pointer; transition: background .2s, color .2s;
}
.nav__acct-menu a:hover, .nav__acct-out:hover { background: var(--accent-dim); color: var(--accent); }
.nav__acct-menu svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; flex-shrink: 0; }
.nav__acct-sep { height: 1px; background: var(--line); margin: .4rem 0; }
.nav__acct-out { color: var(--muted); }

/* mobile menu, member state */
body.is-member .menu [data-auth] { display: none; }
.menu__member { display: none; }
body.is-member .menu__member { display: contents; }

/* ---------- success overlay (post sign-in transition) ---------- */
.authok { position: fixed; inset: 0; z-index: 600; display: none; align-items: center; justify-content: center; padding: 1.2rem; text-align: center; }
.authok.is-open { display: flex; }
.authok__bg { position: absolute; inset: 0; background: rgba(6,5,4,.9); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); animation: authFade .4s var(--ease); }
.authok__card { position: relative; max-width: 460px; animation: authPop .6s var(--ease); }
.authok__check { width: 76px; height: 76px; margin: 0 auto 1.4rem; border-radius: 50%; border: 1.5px solid var(--line-2); display: grid; place-items: center; color: var(--accent); }
.authok__check svg { width: 38px; height: 38px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 32; stroke-dashoffset: 32; animation: okdraw .6s .25s var(--ease) forwards; }
@keyframes okdraw { to { stroke-dashoffset: 0; } }
.authok__eyebrow { font-size: .64rem; font-weight: 600; letter-spacing: .26em; text-transform: uppercase; color: var(--accent); }
.authok__title { font-family: var(--font-d); font-weight: 500; font-size: clamp(2rem,4vw,2.8rem); line-height: 1.05; margin: .5rem 0; color: var(--text); }
.authok__title em { font-style: italic; color: var(--accent); }
.authok__msg { color: var(--muted); font-size: .95rem; }
.authok__spin { margin: 1.4rem auto 0; width: 26px; height: 26px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: okspin .8s linear infinite; }
@keyframes okspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .authok__check svg { animation: none; stroke-dashoffset: 0; }
  .authok__bg, .authok__card { animation: none; } .authok__spin { animation-duration: 2.4s; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--accent); color: #1a1409; padding: .9em 1.5em; border-radius: 999px;
  font-size: .82rem; font-weight: 600; letter-spacing: .02em; box-shadow: 0 16px 40px rgba(0,0,0,.4);
  opacity: 0; pointer-events: none; z-index: 500; transition: opacity .4s var(--ease), transform .4s var(--ease);
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 480px) {
  .field--row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .auth.is-open .auth__card, .auth.is-open .auth__backdrop { animation: none; }
}
