/* Locked homepage + reset. Internal door. Product chrome stays in portal.css. */
body.locked {
  background: var(--bg, #101114);
  display: block !important;
  height: auto !important;
  min-height: 100dvh;
  overflow: auto !important;
  grid-template-columns: none !important;
}
body.locked .rail,
body.locked .shell,
body.locked .rail-scrim,
body.locked .skip,
body.locked #pickLayer {
  display: none !important;
}
body:not(.locked) #gate { display: none !important; }
html[data-in="1"] #gate { display: none !important; }
html[data-in="1"] body.locked {
  display: grid !important;
  grid-template-columns: var(--rail, 248px) minmax(0, 1fr) !important;
  grid-template-rows: minmax(0, 1fr) !important;
  height: 100dvh !important;
  min-height: 100dvh !important;
  overflow: hidden !important;
  background: var(--bg, #101114);
}
html[data-in="1"] body.locked .rail { display: flex !important; }
html[data-in="1"] body.locked .shell { display: grid !important; }
html[data-in="1"] body.locked .skip { display: unset !important; }
html[data-in="1"] body.locked .rail-scrim,
html[data-in="1"] body.locked #pickLayer { display: none !important; }

#gate {
  --gate-sans: "Source Sans 3", "Sarabun", ui-sans-serif, system-ui, sans-serif;
  --gate-mono: "IBM Plex Mono", ui-monospace, monospace;
  --gate-ink: #e6e8ec;
  --gate-mute: #9aa0a8;
  --gate-line: rgba(255, 255, 255, 0.14);
  --gate-paper: #f4f5f7;
  --gate-bg: #0c0d10;
  --gate-panel: #16181d;
  --gate-field: #1a1c22;
  --gate-cta: #f4f5f7;
  --gate-cta-ink: #12141a;
  --gate-accent: #3e6ae1;
  --gate-radius: 2px;
  --gate-ctl: 48px;
  --gate-col: 400px;
  --gate-shadow: 0 18px 48px rgb(0 0 0 / 0.32);
  display: grid;
  min-height: 100dvh;
  padding: 0;
  background: var(--gate-bg);
  color: var(--gate-ink);
  font-family: var(--gate-sans);
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: 0;
  font-variant-ligatures: none;
  isolation: isolate;
  color-scheme: dark;
}
html[data-theme="light"] #gate {
  --gate-ink: #16181d;
  --gate-mute: #5e636b;
  --gate-line: rgba(22, 24, 29, 0.12);
  --gate-paper: #16181d;
  --gate-bg: #eef0f3;
  --gate-panel: #ffffff;
  --gate-field: #f3f4f6;
  --gate-cta: #16181d;
  --gate-cta-ink: #f7f8fa;
  --gate-shadow: 0 18px 40px rgb(22 24 29 / 0.12);
  color-scheme: light;
}
#gate [lang="th"] {
  font-family: "Sarabun", "Source Sans 3", ui-sans-serif, sans-serif;
}
html[lang="th"] #gate .en { display: none; }
html:not([lang="th"]) #gate .th { display: none; }
#gate button, #gate input {
  font-family: inherit;
  border-radius: var(--gate-radius);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#gate [hidden] { display: none !important; }

.gate-grain {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.55'/></svg>");
  mix-blend-mode: overlay;
}
html[data-theme="light"] .gate-grain {
  opacity: 0.05;
  mix-blend-mode: multiply;
}

.gate-hero {
  position: relative;
  min-height: 100dvh;
  display: grid;
  isolation: isolate;
  overflow: hidden;
}
.gate-hero::after {
  content: "";
  position: absolute;
  inset: 14px;
  z-index: 2;
  pointer-events: none;
  border: 1px solid var(--gate-line);
}
.gate-media {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--gate-bg) url("/bkk-field.jpg") center 40% / cover no-repeat;
}
.gate-media video,
.gate-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
  filter: grayscale(0.32) contrast(1.16) saturate(0.82) brightness(0.5);
}
html[data-theme="light"] .gate-media video,
html[data-theme="light"] .gate-media img {
  filter: grayscale(0.06) contrast(1.14) saturate(0.92) brightness(0.9);
}
.gate-veil {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(58% 52% at 50% 46%, rgb(12 13 16 / .22) 0%, rgb(12 13 16 / .58) 48%, rgb(12 13 16 / .86) 100%),
    linear-gradient(180deg, rgb(12 13 16 / .5) 0%, transparent 30%, rgb(12 13 16 / .9) 100%);
}
html[data-theme="light"] .gate-veil {
  background:
    radial-gradient(58% 52% at 50% 46%, rgb(247 248 250 / .18) 0%, rgb(247 248 250 / .42) 46%, rgb(247 248 250 / .78) 100%),
    linear-gradient(180deg, rgb(247 248 250 / .28) 0%, transparent 28%, rgb(247 248 250 / .72) 100%);
}

.pitch {
  position: relative;
  z-index: 3;
  width: min(1280px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 24px max(16px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: 64px 1fr auto;
  justify-items: center;
}
.pitch-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 64px;
}
.pitch-nav .mark {
  color: var(--gate-ink);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
}
.pitch-hero {
  width: min(var(--gate-col), 100%);
  justify-self: center;
  align-self: center;
  text-align: center;
  padding: 0;
}
.pitch-hero h1 {
  font-weight: 600;
  font-size: clamp(2.15rem, 4.6vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.038em;
  margin: 0 0 10px;
  color: var(--gate-ink);
  text-wrap: balance;
}
.pitch-hero .lede {
  color: var(--gate-ink);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.45;
  max-width: 36ch;
  margin: 0 auto 28px;
  opacity: 0.86;
  text-wrap: balance;
}

.sign-panel {
  width: 100%;
  display: grid;
  justify-items: stretch;
}
#gate .enter {
  width: 100%;
  height: var(--gate-ctl);
  min-width: 0;
  padding: 0 22px;
  font-size: 15px !important;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  background: var(--gate-cta);
  color: var(--gate-cta-ink);
  border: 0;
  cursor: pointer;
  white-space: nowrap;
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, #fff 18%, transparent),
    var(--gate-shadow);
}
#gate .enter:hover { filter: brightness(1.06); }
#gate .enter:active { transform: scale(0.985); }
#gate .enter:focus-visible,
#gate .pass-row button:focus-visible,
#gate .pass-row input:focus-visible,
#gate .show-pass:focus-visible,
#gate .lang-opt:focus-visible,
#gate .theme-opt:focus-visible {
  outline: 2px solid var(--gate-cta);
  outline-offset: 3px;
}
.pass-drop {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  margin-top: 0;
  width: 100%;
  text-align: left;
  transition: grid-template-rows 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s cubic-bezier(0.22, 1, 0.36, 1), margin 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.pass-drop > .pass-inner { overflow: hidden; min-height: 0; }
.pass-drop.open {
  grid-template-rows: 1fr;
  opacity: 1;
}
.pass-drop.open > .pass-inner { overflow: visible; }
.pass-inner {
  display: grid;
  gap: 10px;
  padding: 18px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--gate-ink) 5%, var(--gate-panel)), var(--gate-panel));
  border: 1px solid var(--gate-line);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, #fff 10%, transparent),
    var(--gate-shadow);
}
.pass-drop label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gate-mute);
  text-align: left;
}
.pass-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 20px;
}
.pass-head label { margin: 0; flex: 1; min-width: 0; }
.pass-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.pass-field { position: relative; flex: 1; min-width: 0; }
#gate .pass-row input,
#gate input[type="email"],
#gate input[type="password"],
#gate input[type="text"],
#gate input.secret {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  height: var(--gate-ctl);
  padding: 0 14px;
  font-size: 16px;
  letter-spacing: 0;
  text-transform: none;
  background: var(--gate-field);
  border: 1px solid var(--gate-line);
  color: var(--gate-ink);
  text-align: left;
  cursor: text;
  pointer-events: auto;
  -webkit-user-select: text;
  user-select: text;
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--gate-ink) 4%, transparent);
}
#gate input.secret:not(.revealed) {
  -webkit-text-security: disc;
  text-security: disc;
}
#gate input.secret.revealed {
  -webkit-text-security: none;
  text-security: none;
}
#gate .pass-row input:focus,
#gate input[type="email"]:focus,
#gate input[type="password"]:focus,
#gate input[type="text"]:focus,
#gate input.secret:focus {
  border-color: color-mix(in srgb, var(--gate-ink) 45%, var(--gate-line));
  outline: none;
}
#gate .pass-row button[type="submit"],
#gate #saveBtn {
  height: var(--gate-ctl);
  padding: 0 18px;
  letter-spacing: 0;
  text-transform: none;
  background: var(--gate-cta);
  color: var(--gate-cta-ink);
  border: 0;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 600;
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 16%, transparent);
}
#gate .pass-row button[type="submit"]:hover,
#gate #saveBtn:hover { filter: brightness(1.06); }
#gate .pass-row button[type="submit"]:disabled,
#gate #saveBtn:disabled { opacity: 0.55; cursor: wait; }
#gate .show-pass {
  position: static;
  flex: 0 0 auto;
  height: 32px !important;
  min-height: 32px !important;
  min-width: 44px;
  width: auto !important;
  max-width: none;
  padding: 0 4px !important;
  margin: 0;
  background: none !important;
  border: 0 !important;
  box-shadow: none !important;
  color: var(--gate-mute);
  font-size: 11px !important;
  font-weight: 600 !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
  line-height: 1 !important;
  cursor: pointer;
  z-index: auto;
  user-select: none;
  -webkit-user-select: none;
}
#gate .show-pass .hide-on { display: none; }
#gate .show-pass[aria-pressed="true"] .show-on { display: none; }
#gate .show-pass[aria-pressed="true"] .hide-on { display: inline; }
#gate .show-pass:hover,
#gate .show-pass[aria-pressed="true"] { color: var(--gate-ink); }
.pass-drop .err,
#gate .err {
  color: var(--gate-mute);
  font-size: 13px;
  min-height: 16px;
  text-align: left;
}
#gate .forgot {
  justify-self: center;
  height: auto !important;
  min-height: 44px;
  padding: 8px 0 !important;
  background: none !important;
  border: 0 !important;
  color: var(--gate-mute) !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  cursor: pointer;
  box-shadow: none !important;
}
#gate .forgot:hover { color: var(--gate-ink) !important; }

.gate-peek {
  width: 100%;
  margin-top: 36px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 12px;
  color: var(--gate-mute);
  font-family: var(--gate-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.35;
}
.gate-peek span { min-width: 0; }

.gate-dock {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 0 8px;
}
#gate .gate-dock .theme-seg,
#gate .gate-dock .lang-seg {
  background: color-mix(in srgb, var(--gate-panel) 78%, transparent) !important;
  border-color: var(--gate-line) !important;
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--gate-ink) 8%, transparent),
    0 10px 24px rgb(0 0 0 / 0.16) !important;
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
}
html[data-theme="light"] #gate .gate-dock .theme-seg,
html[data-theme="light"] #gate .gate-dock .lang-seg {
  background: rgb(255 255 255 / 0.9) !important;
  border-color: rgb(22 24 29 / 0.14) !important;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.9),
    0 12px 24px rgb(22 24 29 / 0.1) !important;
}
#gate .gate-dock .theme-opt {
  color: var(--gate-mute) !important;
}
#gate .gate-dock .theme-opt.on {
  background: color-mix(in srgb, var(--gate-ink) 10%, transparent) !important;
  color: var(--gate-ink) !important;
}
#gate .gate-dock .lang-seg {
  height: 36px !important;
}
#gate .gate-dock .lang-opt {
  color: var(--gate-mute) !important;
}
#gate .gate-dock .lang-opt.on {
  color: var(--gate-ink) !important;
  background: color-mix(in srgb, var(--gate-ink) 10%, transparent) !important;
}

@media (prefers-reduced-motion: no-preference) {
  .pitch-nav,
  .pitch-hero,
  .gate-dock {
    animation: gateIn 0.64s cubic-bezier(0.22, 1, 0.36, 1) both;
  }
  .pitch-hero { animation-delay: 0.06s; }
  .gate-dock { animation-delay: 0.12s; }
}
@keyframes gateIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .gate-media video { display: none; }
  .pitch-nav, .pitch-hero, .gate-dock { animation: none; }
  #gate .enter:active { transform: none; }
  .pass-drop { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  #gate .gate-dock .theme-seg,
  #gate .gate-dock .lang-seg {
    background: var(--gate-panel) !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}
@media print {
  .gate-hero, .pitch { min-height: 0; }
  .gate-media, .gate-veil, .gate-grain, .gate-hero::after { display: none; }
}

@media (max-width: 860px) {
  #gate { font-size: 16px; }
  .gate-hero::after { inset: 0; border: 0; }
  .pitch {
    padding: 10px 20px calc(14px + env(safe-area-inset-bottom));
    grid-template-rows: 52px 1fr auto;
  }
  .pitch-nav { height: 52px; }
  .pitch-hero h1 { font-size: clamp(2rem, 10vw, 2.5rem); }
  .pitch-hero .lede { font-size: 16px; margin-bottom: 24px; }
  .gate-peek {
    margin-top: 28px;
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .pass-row { flex-direction: column; }
  .pass-inner { padding: 16px; }
  #gate .enter,
  #gate .pass-row > button[type="submit"],
  #gate .pass-row input,
  #gate #saveBtn {
    width: 100%;
    height: var(--gate-ctl);
    min-height: var(--gate-ctl);
    font-size: 16px !important;
  }
  #gate .show-pass {
    width: auto !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 8px !important;
  }
  #gate .gate-dock .theme-seg,
  #gate .gate-dock .lang-seg { height: 40px !important; }
  #gate .gate-dock .theme-opt {
    width: 40px !important;
    height: 36px !important;
    min-width: 40px !important;
  }
  #gate .gate-dock .lang-opt {
    height: 36px !important;
    min-width: 40px !important;
  }
}
