/* Panalo Students — base: reset, type, controls, dialogs, toasts, states. */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 var(--f-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

img,
svg,
canvas,
video {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-weight: 600;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

a {
  color: inherit;
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

::selection {
  background: rgba(154, 216, 255, 0.3);
}

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

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: var(--r-1);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus {
  top: 12px;
}

/* ---- Type ---------------------------------------------------------------- */

.kicker {
  font: 600 11px/1.2 var(--f-body);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
}
.kicker.toned {
  color: var(--tone, var(--text-3));
}

.display {
  font-family: var(--f-display);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.02;
}

.serif {
  font-family: var(--f-serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0;
}

.num {
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--text-2);
}
.faint {
  color: var(--text-3);
}

/* ---- Buttons -------------------------------------------------------------- */

.btn {
  --h: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--h);
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: none;
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1), transform var(--dur-1) var(--ease-out);
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover:not(:disabled) {
  background: #fff;
}
.btn-ghost {
  border-color: var(--line-2);
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--line-3);
  background: rgba(255, 255, 255, 0.04);
}
.btn-quiet {
  padding: 0 10px;
  color: var(--text-2);
}
.btn-quiet:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}
.btn-danger {
  border-color: rgba(255, 143, 128, 0.4);
  color: var(--alert);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(255, 143, 128, 0.1);
}
.btn-toned {
  border-color: color-mix(in srgb, var(--tone) 45%, transparent);
  color: var(--tone);
}
.btn-toned:hover:not(:disabled) {
  background: color-mix(in srgb, var(--tone) 12%, transparent);
}
.btn-lg {
  --h: 52px;
  padding: 0 26px;
  font-size: 15px;
}
.btn-sm {
  --h: 34px;
  padding: 0 14px;
  font-size: 13px;
}
.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--r-pill);
  background: none;
  color: var(--text-2);
  transition: background var(--dur-1), color var(--dur-1);
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}
.icon-btn.sm {
  width: 32px;
  height: 32px;
}

/* ---- Fields --------------------------------------------------------------- */

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}
.field > span,
.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}
.input,
.field input,
.field select,
.field textarea,
.birth-row select,
.birth-row input {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  background: rgba(7, 9, 18, 0.7);
  color: var(--text);
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
.field textarea {
  min-height: 90px;
  resize: vertical;
}
.input::placeholder,
.field input::placeholder,
.birth-row input::placeholder,
.field textarea::placeholder {
  color: var(--text-3);
}
.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus,
.birth-row select:focus,
.birth-row input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(154, 216, 255, 0.16);
}
.field select,
.birth-row select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field-hint {
  font-size: 12.5px;
  color: var(--text-3);
}
.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13.5px;
  color: var(--text-2);
}
.check input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--focus);
  flex: none;
}

/* ---- Chips ---------------------------------------------------------------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  background: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--dur-1);
}
.chip:hover {
  color: var(--text);
  border-color: var(--line-3);
}
.chip[aria-pressed="true"],
.chip[aria-checked="true"],
.chip[aria-selected="true"] {
  border-color: var(--tone, var(--accent));
  color: var(--text);
  background: color-mix(in srgb, var(--tone, var(--accent)) 14%, transparent);
}
.chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tone, var(--text-3));
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  border: 1px solid color-mix(in srgb, var(--tone, var(--text-3)) 40%, transparent);
  color: var(--tone, var(--text-2));
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ---- Dialogs -------------------------------------------------------------- */

dialog.sheet {
  width: min(520px, calc(100vw - 32px));
  max-height: min(86vh, 760px);
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r-3);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
dialog.sheet[open] {
  display: flex;
  flex-direction: column;
  animation: sheet-in var(--dur-2) var(--ease-out);
}
dialog.sheet.wide {
  width: min(760px, calc(100vw - 32px));
}
dialog.sheet::backdrop {
  background: rgba(3, 4, 10, 0.72);
  backdrop-filter: blur(3px);
}
.sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 22px 22px 6px;
}
.sheet-head h2 {
  font-size: 19px;
  flex: 1;
}
.sheet-head p {
  margin-top: 6px;
  font-size: 13.5px;
  color: var(--text-2);
}
.sheet-body {
  padding: 14px 22px 4px;
  overflow-y: auto;
}
.sheet-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px 20px;
  border-top: 1px solid var(--line);
}
@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
}
@media (max-width: 640px) {
  dialog.sheet,
  dialog.sheet.wide {
    width: 100vw;
    max-width: 100vw;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: var(--r-3) var(--r-3) 0 0;
    border-bottom: 0;
  }
  dialog.sheet[open] {
    animation-name: sheet-up;
  }
  .sheet-foot {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
  @keyframes sheet-up {
    from {
      transform: translateY(40px);
      opacity: 0;
    }
  }
}

/* ---- Toasts (src/util.js showToast) ------------------------------------- */

#toast-container[popover] {
  /* The top layer, not a dialog: undo the popover defaults. */
  inset: auto auto calc(var(--dock-h) + 16px + env(safe-area-inset-bottom)) 50%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
  color: inherit;
}
@media (min-width: 900px) {
  #toast-container[popover] {
    bottom: 24px;
  }
}
.sheet-alert {
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 143, 128, 0.45);
  border-radius: var(--r-2);
  background: rgba(255, 143, 128, 0.08);
  color: var(--text);
  font-size: 14px;
}
.sheet-alert:empty {
  display: none;
}
#toast-container {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-h) + 16px + env(safe-area-inset-bottom));
  z-index: 90;
  display: grid;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}
@media (min-width: 900px) {
  #toast-container {
    bottom: 24px;
  }
}
.toast {
  padding: 12px 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  background: var(--surface-3);
  color: var(--text);
  font-size: 14px;
  box-shadow: var(--shadow-2);
  animation: sheet-in var(--dur-2) var(--ease-out);
  transition: opacity 0.3s;
}
.toast-error {
  border-color: rgba(255, 143, 128, 0.45);
}
.toast-success {
  border-color: rgba(134, 232, 180, 0.45);
}
.toast-hide {
  opacity: 0;
}

/* ---- States ---------------------------------------------------------------- */

.empty {
  display: grid;
  justify-items: start;
  gap: 10px;
  padding: 28px 0;
  color: var(--text-2);
  max-width: 46ch;
}
.empty h3 {
  font-size: 16px;
  color: var(--text);
}
.empty p {
  font-size: 14px;
}

.loading-line {
  height: 2px;
  width: 100%;
  overflow: hidden;
  background: var(--line);
  border-radius: 2px;
}
.loading-line::after {
  content: "";
  display: block;
  height: 100%;
  width: 30%;
  background: var(--focus);
  animation: sweep 1.1s var(--ease-cine) infinite;
}
@keyframes sweep {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(340%);
  }
}

.error-line {
  color: var(--alert);
  font-size: 13.5px;
}

.divider {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: 20px 0;
}

/* Lists that read like a log: a time gutter, then the line. */
.log {
  list-style: none;
  margin: 0;
  padding: 0;
}
.log > li {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.log > li:first-child {
  border-top: 0;
}
.log .t {
  font-size: 12.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}

/* Turnstile bot check (src/captcha.js): invisible for most people; when a
   visitor must interact, it sits in the middle of the screen. */
.captcha-box {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 10000;
  transform: translate(-50%, -50%);
}
.captcha-box:empty {
  pointer-events: none;
}
