/* Winsta portal — cyberpunk theme. No external fonts/scripts (CSP: 'self' only). */
:root {
  --bg: #05060a;
  --panel: rgba(10, 14, 24, 0.86);
  --panel-solid: #0a0e18;
  --line: rgba(0, 240, 255, 0.22);
  --text: #e6f7ff;
  --muted: #7d93ab;
  --cyan: #00f0ff;
  --magenta: #ff2a6d;
  --yellow: #f9f002;
  --ok: #3dffa8;
  --danger: #ff3b5c;
  --mono: "Cascadia Mono", "Consolas", "SFMono-Regular", "Menlo", ui-monospace, monospace;
  --sans: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  --cut: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 500px at 85% -10%, rgba(255, 42, 109, 0.18), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(0, 240, 255, 0.14), transparent 60%),
    linear-gradient(rgba(0, 240, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.05) 1px, transparent 1px);
  background-size: auto, auto, 40px 40px, 40px 40px;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* CRT scanlines over everything, never blocks taps */
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 3px);
  z-index: 50;
}

h1 { margin: 0; font-size: 1.6rem; font-weight: 800; letter-spacing: 0.04em; }
p { margin: 0; }
a { color: var(--cyan); }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; }

.kicker {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  color: var(--cyan);
  text-transform: uppercase;
  opacity: 0.85;
}

/* ------------------------------------------------------------ glitch logo */
.logo {
  position: relative;
  display: inline-block;
  font-family: var(--mono);
  font-weight: 900;
  font-size: clamp(2.4rem, 11vw, 3.4rem);
  letter-spacing: 0.14em;
  line-height: 1.1;
  color: var(--text);
  text-decoration: none;
  text-shadow: 0 0 18px rgba(0, 240, 255, 0.55);
}
.logo::before, .logo::after {
  content: attr(data-text);
  position: absolute; left: 0; top: 0;
  width: 100%;
  overflow: hidden;
  pointer-events: none;
}
.logo::before { color: var(--magenta); transform: translate(-2px, 0); clip-path: inset(0 0 55% 0); animation: glitch-a 3.2s infinite steps(1); mix-blend-mode: screen; }
.logo::after  { color: var(--cyan);    transform: translate(2px, 0);  clip-path: inset(55% 0 0 0); animation: glitch-b 2.7s infinite steps(1); mix-blend-mode: screen; }
.logo.small { font-size: 1.25rem; letter-spacing: 0.2em; text-shadow: 0 0 10px rgba(0, 240, 255, 0.5); }

@keyframes glitch-a {
  0%, 88%, 100% { transform: translate(-2px, 0); clip-path: inset(0 0 55% 0); }
  90% { transform: translate(-6px, -1px); clip-path: inset(10% 0 70% 0); }
  93% { transform: translate(4px, 1px); clip-path: inset(40% 0 30% 0); }
  96% { transform: translate(-3px, 0); clip-path: inset(70% 0 5% 0); }
}
@keyframes glitch-b {
  0%, 84%, 100% { transform: translate(2px, 0); clip-path: inset(55% 0 0 0); }
  86% { transform: translate(6px, 1px); clip-path: inset(60% 0 15% 0); }
  90% { transform: translate(-4px, -1px); clip-path: inset(20% 0 55% 0); }
}

/* ------------------------------------------------------------ panels */
.panel, .card {
  position: relative;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  box-shadow: inset 0 0 40px rgba(0, 240, 255, 0.05);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.corner { position: absolute; width: 22px; height: 22px; pointer-events: none; }
.corner.tl { top: 6px; left: 6px; border-top: 2px solid var(--cyan); border-left: 2px solid var(--cyan); }
.corner.br { bottom: 6px; right: 6px; border-bottom: 2px solid var(--magenta); border-right: 2px solid var(--magenta); }

body.center {
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

/* simple message pages (403 etc.) rendered by main._page */
.card { padding: 32px 26px; }
.card.narrow { max-width: 400px; }
.card h1 { color: var(--magenta); font-family: var(--mono); text-shadow: 0 0 12px rgba(255, 42, 109, 0.5); }
.card.narrow > p { margin: 14px 0 24px; color: var(--muted); }
.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 0 20px;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  background: rgba(0, 240, 255, 0.06);
  font-family: var(--mono); font-weight: 700; letter-spacing: 0.08em;
  text-decoration: none;
}
.button:hover { background: rgba(0, 240, 255, 0.16); }

/* ------------------------------------------------------------ login */
.login { max-width: 420px; padding: 36px 30px 22px; }
.login-head { margin-bottom: 26px; }
.login-head .kicker { margin-bottom: 6px; }
.tagline { color: var(--muted); font-size: 0.92rem; margin-top: 4px; }

.alert {
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 18px;
  padding: 10px 12px;
  border-left: 3px solid var(--danger);
  background: rgba(255, 59, 92, 0.1);
  color: #ffc2cd;
  font-size: 0.92rem;
  animation: shake 0.35s ease-out;
}
.alert-tag {
  flex: none;
  font-family: var(--mono); font-size: 0.7rem; font-weight: 700;
  padding: 2px 6px; margin-top: 2px;
  background: var(--danger); color: #12030a;
}
@keyframes shake {
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.login-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 0.9rem; color: var(--text); font-weight: 600; }
.field-label em {
  font-style: normal; font-family: var(--mono); font-size: 0.7rem;
  letter-spacing: 0.14em; color: var(--muted); margin-left: 6px;
}

input[type="text"], input[type="password"] {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(0, 240, 255, 0.28);
  border-radius: 0;
  color: var(--text);
  font: inherit;
  font-size: 16px; /* >= 16px keeps iOS from zooming in */
  caret-color: var(--yellow);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input[type="text"]:focus, input[type="password"]:focus {
  border-color: var(--cyan);
  background: rgba(0, 240, 255, 0.05);
  box-shadow: 0 0 0 1px var(--cyan), 0 0 18px rgba(0, 240, 255, 0.3);
}
input:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px #061018 inset;
  transition: background-color 9999s;
}

.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 72px; }
.pw-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  min-width: 56px; min-height: 38px;
  border: 1px solid rgba(0, 240, 255, 0.3);
  background: transparent;
  color: var(--cyan);
  font: 600 0.8rem var(--sans);
  cursor: pointer;
}
.pw-toggle:hover { background: rgba(0, 240, 255, 0.1); }
.caps { font-size: 0.8rem; color: var(--yellow); font-family: var(--mono); }

.check {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.92rem;
  user-select: none;
}
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-box {
  flex: none; width: 22px; height: 22px;
  border: 1px solid var(--cyan);
  display: grid; place-items: center;
  transition: background 0.15s, box-shadow 0.15s;
}
.check input:checked + .check-box { background: var(--cyan); box-shadow: 0 0 12px rgba(0, 240, 255, 0.6); }
.check input:checked + .check-box::after { content: "✓"; color: #001014; font-weight: 900; font-size: 0.85rem; }
.check input:focus-visible + .check-box { outline: 2px solid var(--yellow); outline-offset: 3px; }
.check input:checked ~ span:last-child { color: var(--text); }

.btn-neon {
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 54px;
  margin-top: 4px;
  border: none;
  background: var(--yellow);
  color: #0a0a00;
  font: 900 1.05rem var(--sans);
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  cursor: pointer;
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  box-shadow: 0 0 24px rgba(249, 240, 2, 0.35);
  transition: filter 0.15s, transform 0.1s;
}
.btn-neon:hover { filter: brightness(1.1) drop-shadow(0 0 8px rgba(249, 240, 2, 0.6)); }
.btn-neon:active { transform: translateY(1px); }
.btn-arrow { letter-spacing: 0; text-indent: 0; transition: transform 0.2s; }
.btn-neon:hover .btn-arrow { transform: translateX(4px); }
.btn-neon.busy { pointer-events: none; filter: saturate(0.6); }
.btn-neon.busy .btn-arrow { animation: blink 0.6s infinite; }

.login-foot {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 26px; padding-top: 14px;
  border-top: 1px dashed rgba(0, 240, 255, 0.18);
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em;
  color: var(--muted);
}
.blink { color: var(--ok); animation: blink 2s infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

/* ------------------------------------------------------------ home */
body.home-page { display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left));
  background: rgba(5, 6, 10, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who form { margin: 0; }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-width: 0; max-width: 40vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--mono); font-size: 0.85rem; color: var(--text);
}
.user-dot { flex: none; width: 8px; height: 8px; background: var(--ok); box-shadow: 0 0 8px var(--ok); border-radius: 50%; }
.btn-ghost {
  min-height: 40px; padding: 0 16px;
  border: 1px solid rgba(255, 42, 109, 0.6);
  background: transparent;
  color: var(--magenta);
  font: 700 0.85rem var(--sans);
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn-ghost:hover { background: rgba(255, 42, 109, 0.12); box-shadow: 0 0 14px rgba(255, 42, 109, 0.35); }

.home {
  flex: 1;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 44px max(20px, env(safe-area-inset-right)) 32px max(20px, env(safe-area-inset-left));
}
.hero { margin-bottom: 28px; }
.hero h1 { font-size: clamp(1.6rem, 6vw, 2.4rem); margin: 6px 0 8px; text-shadow: 0 0 20px rgba(0, 240, 255, 0.25); }
.sys-line { font-family: var(--mono); font-size: 0.82rem; color: var(--muted); letter-spacing: 0.06em; }
#clock { color: var(--yellow); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 18px; }

.tile {
  --accent: var(--cyan);
  --accent-rgb: 0, 240, 255;
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "top top" "icon name" "icon sub" "go go";
  column-gap: 18px;
  padding: 22px 22px 20px;
  min-height: 210px;
  background: linear-gradient(160deg, rgba(var(--accent-rgb), 0.09), rgba(10, 14, 24, 0.9) 55%);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
}
.tile-video { --accent: var(--magenta); --accent-rgb: 255, 42, 109; }
.tile-music { --accent: var(--yellow); --accent-rgb: 249, 240, 2; }
.tile .corner.tl { border-color: var(--accent); }
.tile .corner.br { border-color: var(--accent); }
.tile:hover, .tile:focus-visible {
  transform: translateY(-3px);
  background: linear-gradient(160deg, rgba(var(--accent-rgb), 0.18), rgba(10, 14, 24, 0.9) 60%);
  box-shadow: inset 0 0 30px rgba(var(--accent-rgb), 0.18);
}
.tile:active { transform: translateY(0) scale(0.99); }
/* light sweep on hover */
.tile::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(var(--accent-rgb), 0.22) 50%, transparent 60%);
  transform: translateX(-100%);
  pointer-events: none;
}
.tile:hover::after { transform: translateX(100%); transition: transform 0.7s ease; }

.tile-top { grid-area: top; display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 8px; }
.tile-code { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.16em; color: rgba(var(--accent-rgb), 0.85); }

.tile-icon {
  grid-area: icon; align-self: center;
  width: 64px; height: 64px;
  display: grid; place-items: center;
  border: 1px solid var(--accent);
  background: rgba(var(--accent-rgb), 0.1);
  box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.35), inset 0 0 14px rgba(var(--accent-rgb), 0.25);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
.tile-icon svg { width: 32px; height: 32px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 4px var(--accent)); }

.tile-name { grid-area: name; align-self: end; font-size: 1.45rem; font-weight: 800; letter-spacing: 0.06em; }
.tile-sub { grid-area: sub; align-self: start; color: var(--muted); font-size: 0.9rem; }
.tile-go {
  grid-area: go;
  margin-top: 20px; padding-top: 12px;
  border-top: 1px dashed rgba(var(--accent-rgb), 0.3);
  font-family: var(--mono); font-weight: 700; font-size: 0.9rem; letter-spacing: 0.2em;
  color: var(--accent);
  text-align: right;
}
.tile-go span { display: inline-block; transition: transform 0.2s; }
.tile:hover .tile-go span { transform: translateX(5px); }

.status {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 9px;
  border: 1px solid rgba(125, 147, 171, 0.4);
  font-family: var(--mono); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em;
  color: var(--muted);
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.online { color: var(--ok); border-color: rgba(61, 255, 168, 0.5); }
.status.online::before { box-shadow: 0 0 8px var(--ok); animation: blink 1.6s infinite; }
.status.offline { color: var(--danger); border-color: rgba(255, 59, 92, 0.5); }

.tile.is-offline { filter: saturate(0.35); }
.tile.is-offline .tile-go { color: var(--muted); }

.hint, .empty { margin-top: 22px; color: var(--muted); font-size: 0.85rem; }
.empty { font-size: 1rem; }

.footbar {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px max(20px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.16em;
  color: var(--muted);
}

/* ------------------------------------------------------------ phones */
@media (max-width: 560px) {
  .login { padding: 30px 20px 18px; }
  .home { padding-top: 28px; }
  .hero { margin-bottom: 20px; }
  .grid { gap: 14px; }
  .tile { min-height: 0; padding: 18px 18px 16px; column-gap: 16px; }
  .tile-top { margin-bottom: 14px; }
  .tile-icon { width: 56px; height: 56px; }
  .tile-go { margin-top: 14px; }
  .footbar span:last-child { display: none; }
}

@media (hover: none) {
  .tile:hover { transform: none; }
  .tile:hover::after { transform: translateX(-100%); transition: none; }
}

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