/* ICS FORGE — style.css
   Dark arcade / retro-terminal. Part of THE LAB.
   Pixel type (Press Start 2P) drives the title + HUD labels; the working
   form controls stay clean monospace/terminal for legibility. */

/* ---------- fonts (self-hosted, shared with the lab root) ---------- */

@font-face { font-family: "Press Start 2P"; font-style: normal; font-weight: 400; font-display: swap; src: url("/press-start-2p.woff2") format("woff2"); }
@font-face { font-family: "Press Start 2P Fallback"; src: local("Courier New"); size-adjust: 166.64%; ascent-override: 60%; descent-override: 0%; line-gap-override: 0%; }

/* ---------- tokens ---------- */

:root {
  --bg: #0a0a12;
  --surface: #12121d;
  --surface-2: #1a1a2a;
  --surface-3: #20202f;
  --line: #28283c;
  --control-line: #5e5e80; /* >=3:1 against surface for control boundaries */
  --text: #e9e9f2;
  --dim: #9aa0b5;
  --cyan: #45f0ff;
  --magenta: #ff3d8b;
  --gold: #ffc857;
  --green: #41ff8b;
  --red: #ff5560;

  --pixel: "Press Start 2P", "Press Start 2P Fallback", "Courier New", monospace;
  --body: -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --radius: 8px;
  --radius-sm: 5px;
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --glow-cyan: 0 0 14px rgba(69, 240, 255, 0.35);
  --glow-gold: 0 0 14px rgba(255, 200, 87, 0.35);
  --space-gutter: clamp(16px, 4vw, 40px);
}

/* ---------- base ---------- */

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

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 20rem;
  min-height: 100svh;
  background:
    radial-gradient(1100px 480px at 50% -8%, rgba(69, 240, 255, 0.06), transparent 70%),
    radial-gradient(900px 520px at 90% 110%, rgba(255, 61, 139, 0.05), transparent 72%),
    var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(69, 240, 255, 0.3); color: var(--text); }

[hidden] { display: none !important; }

a { color: var(--cyan); }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(69, 240, 255, 0.18);
  border-radius: 2px;
}

/* ---------- CRT scanline texture ---------- */

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.10) 0 1px,
    transparent 1px 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.55;
}

/* ---------- skip + back-to-lab links ---------- */

.skip-link {
  position: absolute;
  left: 12px;
  top: -56px;
  z-index: 200;
  background: var(--cyan);
  color: #05050d;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-weight: 700;
  text-decoration: none;
  transition: transform var(--duration-normal) var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(70px); }

.lab-link {
  position: fixed;
  left: 14px;
  top: 14px;
  z-index: 120;
  display: inline-flex;
  align-items: center;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--dim);
  text-decoration: none;
  padding: 8px 10px;
  background: rgba(10, 10, 18, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: color var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease,
    transform var(--duration-fast) var(--ease-out);
}
.lab-link:hover,
.lab-link:focus-visible {
  color: var(--cyan);
  border-color: var(--cyan);
  box-shadow: var(--glow-cyan);
  transform: translateX(-2px);
}

/* ---------- shell ---------- */

.app-shell {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 80rem;
  margin: 0 auto;
  padding: clamp(3.75rem, 8vw, 4.5rem) var(--space-gutter) 2rem;
}

/* ---------- header ---------- */

.page-header {
  max-width: 56rem;
  margin: 0 auto clamp(1.75rem, 4vw, 2.75rem);
  text-align: center;
}

.kicker {
  margin: 0 0 1rem;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 200, 87, 0.35);
}

.wordmark {
  position: relative;
  margin: 0;
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(24px, 6.5vw, 56px);
  line-height: 1.1;
  letter-spacing: 2px;
  color: var(--text);
  text-shadow:
    0 0 20px rgba(69, 240, 255, 0.45),
    3px 3px 0 var(--magenta);
}

.lede {
  margin: 1.25rem auto 0;
  max-width: 40rem;
  color: var(--dim);
  font-size: clamp(0.95rem, 0.9rem + 0.4vw, 1.1rem);
}

.lede__hi {
  color: var(--cyan);
  font-family: var(--mono);
  font-weight: 700;
}

/* ---------- grid ---------- */

.app-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(1rem, 2.5vw, 1.5rem);
  align-items: start;
}

/* ---------- panels ---------- */

.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 2.5vw, 1.6rem);
  background:
    linear-gradient(180deg, var(--surface-2), var(--surface) 64%);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

/* notch tab on top of each panel */
.panel::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 1.4rem;
  width: 2.6rem;
  height: 4px;
  background: var(--cyan);
  border-radius: 0 0 3px 3px;
  box-shadow: var(--glow-cyan);
}

.preview-panel::before { background: var(--magenta); box-shadow: 0 0 14px rgba(255, 61, 139, 0.4); }

.panel-title {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0 0 1.4rem;
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(11px, 1.6vw, 13px);
  letter-spacing: 1px;
  line-height: 1.5;
  color: var(--text);
}

.panel-title__num {
  display: inline-grid;
  place-items: center;
  min-width: 1.9em;
  padding: 0.45em 0.5em;
  font-size: 0.78em;
  color: var(--bg);
  background: var(--cyan);
  border-radius: 3px;
}

.preview-panel .panel-title__num { background: var(--magenta); }

.subhead {
  margin: 0 0 0.7rem;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--gold);
  text-transform: uppercase;
}

/* ---------- form ---------- */

.event-form {
  display: grid;
  gap: 1.1rem;
}

.field,
.checkbox-field {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
}

.field label,
.zone-picker legend {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--dim);
}

.field-pair {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.1rem;
}

input,
select,
textarea {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--control-line);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  background: var(--surface-3);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.92rem;
  transition: border-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease,
    background-color var(--duration-fast) ease;
}

input::placeholder,
textarea::placeholder { color: var(--dim); opacity: 0.7; }

input:hover,
select:hover,
textarea:hover { border-color: #7676a0; }

input:focus,
select:focus,
textarea:focus {
  border-color: var(--cyan);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px rgba(69, 240, 255, 0.18);
}

textarea { resize: vertical; min-height: 5.5rem; line-height: 1.5; }

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--cyan) 50%),
    linear-gradient(135deg, var(--cyan) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 13px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
}

/* ---------- checkbox ---------- */

.checkbox-field {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.checkbox-field input {
  width: 1.25rem;
  height: 1.25rem;
  min-height: 0;
  margin: 0;
  padding: 0;
  accent-color: var(--cyan);
  cursor: pointer;
}

.checkbox-field label {
  font-family: var(--body);
  font-size: 0.92rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  cursor: pointer;
}

/* ---------- zone picker fieldset ---------- */

.zone-picker {
  min-width: 0;
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 1rem 1rem 1.1rem;
  background: rgba(18, 18, 29, 0.5);
}

.zone-picker legend {
  padding: 0 0.5rem;
  color: var(--magenta);
}

.zone-picker__hint {
  margin: 0 0 0.85rem;
  font-size: 0.82rem;
  color: var(--dim);
}

/* ---------- buttons ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.85rem;
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: var(--pixel);
  font-size: 10px;
  letter-spacing: 1px;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) ease,
    color var(--duration-fast) ease,
    border-color var(--duration-fast) ease;
}

.btn-primary {
  border: 0;
  color: var(--bg);
  background: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan), 0 0 24px rgba(69, 240, 255, 0.32);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 0 1px var(--cyan), 0 0 32px rgba(69, 240, 255, 0.5);
}
.btn-primary:active { transform: translateY(1px); }

.btn-ghost {
  border: 1px solid var(--gold);
  color: var(--gold);
  background: transparent;
}
.btn-ghost:hover {
  transform: translateY(-2px);
  background: var(--gold);
  color: var(--bg);
  box-shadow: var(--glow-gold);
}
.btn-ghost:active { transform: translateY(1px); }

/* disabled states */
.btn:disabled,
.button-link.is-disabled {
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
  opacity: 0.45;
  color: var(--dim);
  background: var(--surface-3);
  border: 1px solid var(--line);
  box-shadow: none;
}

/* ---------- form status ---------- */

.form-status {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  min-height: 1.5rem;
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-left: 3px solid var(--red);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: rgba(255, 85, 96, 0.08);
  color: var(--red);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
}
.form-status:empty { display: none; }
.form-status.is-ok {
  border-left-color: var(--green);
  background: rgba(65, 255, 139, 0.08);
  color: var(--green);
}

/* ---------- preview card ---------- */

.event-preview {
  margin-bottom: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(255, 61, 139, 0.07), transparent 60%),
    var(--surface);
}

.event-preview__head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.event-preview__badge {
  flex-shrink: 0;
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 1px;
  color: var(--magenta);
  border: 1px solid rgba(255, 61, 139, 0.5);
  border-radius: 3px;
  padding: 0.4em 0.55em;
}

.event-preview h3 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
  color: var(--text);
}

.preview-list {
  display: grid;
  gap: 0.85rem;
  margin: 0;
}

.preview-list div {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.25rem 0.75rem;
  align-items: baseline;
}

.preview-list dt {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
}

.preview-list dd {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
}

/* ---------- resolved times table ---------- */

.resolved-times { margin-bottom: 1.5rem; }

.resolved-times__scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.85rem;
}

thead th {
  position: sticky;
  top: 0;
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--cyan);
  background: var(--surface-2);
  padding: 0.75rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody th,
tbody td {
  padding: 0.7rem 0.85rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

tbody tr:last-child th,
tbody tr:last-child td { border-bottom: 0; }

tbody tr:first-child th { color: var(--cyan); }

tbody th {
  font-weight: 700;
  color: var(--dim);
  white-space: nowrap;
}

tbody td {
  color: var(--text);
  min-width: 11rem;
}

tbody tr:hover { background: rgba(69, 240, 255, 0.04); }

/* ---------- ics output ---------- */

.ics-output-wrap {
  display: grid;
  gap: 0.6rem;
}

.ics-output {
  min-height: 18rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  background: #0c0c16;
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.6;
  white-space: pre;
  text-shadow: 0 0 6px rgba(65, 255, 139, 0.25);
}
.ics-output:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(65, 255, 139, 0.18);
}

/* ---------- footer ---------- */

.page-footer {
  margin-top: clamp(2.5rem, 6vw, 4rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  text-align: center;
  display: grid;
  gap: 0.6rem;
}

.page-footer__note {
  margin: 0;
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 2px;
  color: var(--green);
}

.page-footer__by {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--dim);
}

.page-footer__by a { text-decoration: none; }
.page-footer__by a:hover { text-decoration: underline; text-shadow: var(--glow-cyan); }

/* ---------- responsive ---------- */

@media (min-width: 768px) {
  .field-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .app-grid {
    grid-template-columns: minmax(20rem, 0.9fr) minmax(0, 1.1fr);
  }
}

@media (max-width: 460px) {
  .preview-list div { grid-template-columns: 1fr; }
  .actions .btn { width: 100%; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  .btn-primary:hover,
  .btn-ghost:hover,
  .lab-link:hover,
  .lab-link:focus-visible { transform: none; }
}
