/* --- App window ---------------------------------------------------------------
   Shared shell for /dashboard/register and /dashboard: one solid window with a
   breadcrumb titlebar, a section sidebar, label/value rows and a key-hint
   footer. Flat surfaces only, so it reads as a tool rather than the landing
   page's glass.
   ---------------------------------------------------------------------------- */

:root {
  --app-page: #0e1b20;
  --app-window: #18272c;
  --app-panel: #121f23;
  --app-hover: rgba(255, 255, 255, 0.06);
  --app-active: rgba(255, 255, 255, 0.08);
  --app-line: rgba(255, 255, 255, 0.1);
  --app-line-strong: rgba(255, 255, 255, 0.18);
  --app-text: #e9eef0;
  --app-muted: rgba(233, 238, 240, 0.72);
  --app-faint: rgba(233, 238, 240, 0.6);
  --app-accent: #ee2b3c;
  --app-accent-soft: rgba(238, 43, 60, 0.18);
  --app-ok: #5fd39a;

  --app-mono: "Geist Mono", ui-monospace, monospace;
  --app-sans: "Geist", system-ui, sans-serif;

  --app-label-width: 210px;
  --app-sidebar-width: 260px;
  --app-gutter: 28px;
  --app-titlebar-height: 60px;
  --app-row-indent: 40px;
}

body:has(.app-page) {
  margin: 0;
  background: var(--app-page);
}

.app-page {
  position: relative;
  min-height: 100vh;
  padding: 5vh 24px;
  box-sizing: border-box;
  color: var(--app-text);
  font-family: var(--app-sans);
  font-size: 15px;
  overflow-x: clip;
}

/* The landing page's logo lattice, much fainter and static. */
.app-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    url("/static/img/goathacks-banner-tile.svg"),
    url("/static/img/goathacks-banner-tile.svg");
  background-size: 520px 320px;
  background-position:
    0 0,
    260px 160px;
  opacity: 0.015;
}

.app-window {
  position: relative;
  max-width: 1120px;
  margin: 0 auto;
  border: 1px solid var(--app-line-strong);
  border-radius: 22px;
  background: var(--app-window);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.app-page a {
  color: inherit;
}

.app-page :focus-visible {
  outline: 2px solid var(--app-accent);
  outline-offset: 2px;
}

/* --- Titlebar ---------------------------------------------------------------- */

/* Sticky like the footer; the fixed height lets the sidebar and section
   anchors sit just below it. */
.app-titlebar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--app-titlebar-height);
  padding: 0 var(--app-gutter);
  box-sizing: border-box;
  border-bottom: 1px solid var(--app-line);
  border-radius: 22px 22px 0 0;
  background: var(--app-window);
  font-family: var(--app-mono);
}

.app-crumbs {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin: 0;
  font-size: 1rem;
  white-space: nowrap;

  a {
    color: var(--app-muted);
    text-decoration: none;
  }

  a:hover {
    color: var(--app-text);
  }
}

.app-prompt {
  color: var(--app-accent);
}

.app-crumb-sep {
  color: var(--app-faint);
}

.app-crumb-current {
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-titlebar-meta {
  flex: none;
  color: var(--app-muted);
  font-size: 0.8rem;
}

.app-save-state {
  margin-right: 4px;
  color: var(--app-faint);
}

/* --- Body ------------------------------------------------------------------ */

.app-body {
  display: grid;
  grid-template-columns: var(--app-sidebar-width) minmax(0, 1fr);
}

.app-sidebar {
  border-right: 1px solid var(--app-line);
}

.app-sidebar-inner {
  position: sticky;
  top: var(--app-titlebar-height);
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 26px 18px;

  h1 {
    margin: 0 12px;
    font-size: 1.55rem;
    font-weight: 600;
    letter-spacing: -0.02em;
  }
}

.app-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;

  a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    color: var(--app-text);
    text-decoration: none;
    transition: background-color 0.15s ease;
  }

  a:hover {
    background: var(--app-hover);
  }

  a[aria-current] {
    background: var(--app-active);
  }
}

.app-step-count {
  color: var(--app-muted);
  font-family: var(--app-mono);
  font-size: 0.78rem;
  white-space: nowrap;
}

.app-steps a.done .app-step-count {
  color: var(--app-ok);
}

.app-note,
.app-section-note {
  margin: 8px 12px 0;
  color: var(--app-muted);
  font-size: 0.88rem;
  line-height: 1.55;

  a {
    color: var(--app-text);
    text-decoration-color: var(--app-accent);
    text-underline-offset: 3px;
  }
}

.app-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 12px;

  img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
  }

  h1 {
    margin: 0;
  }
}

.app-main {
  display: flex;
  flex-direction: column;
  gap: 34px;
  padding: 28px var(--app-gutter) 36px;

  form {
    display: flex;
    flex-direction: column;
    gap: 34px;
  }
}

/* --- Sections and rows ----------------------------------------------------- */

.app-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  /* Clears the sticky footer when a section is scrolled to. */
  scroll-margin: calc(var(--app-titlebar-height) + 24px) 0 120px;

  > legend,
  > h2 {
    margin: 0 0 8px;
    padding: 0;
    color: var(--app-muted);
    font-family: var(--app-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }

  /* <legend> ignores the fieldset's flex gap. */
  > legend {
    margin-bottom: 16px;
  }
}

/* Rows grouped in a wrapper keep the section's row spacing. */
.app-section-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.app-note.app-note-flush {
  margin-left: 0;
  margin-right: 0;
}

.app-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.app-row {
  padding-left: var(--app-row-indent);
}

.app-section-note {
  margin-left: var(--app-row-indent);
}

.app-row {
  display: grid;
  grid-template-columns: var(--app-label-width) minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  min-height: 44px;

  > label,
  > .app-key {
    color: var(--app-muted);
    font-family: var(--app-mono);
    font-size: 0.85rem;
  }
}

.app-req {
  color: var(--app-text);
}

.app-row :is(input:not([type="file"], [type="checkbox"]), select, textarea) {
  width: 100%;
  height: 44px;
  box-sizing: border-box;
  padding: 0 14px;
  border: 1px solid var(--app-line);
  border-radius: 10px;
  background: var(--app-panel);
  color: var(--app-text);
  font: inherit;
  transition: border-color 0.15s ease;
}

.app-row :is(input, select, textarea):hover {
  border-color: var(--app-line-strong);
}

.app-row :is(input, select, textarea):focus {
  outline: none;
  border-color: var(--app-accent);
  box-shadow: 0 0 0 3px var(--app-accent-soft);
}

.app-row input[readonly] {
  border-style: dashed;
  background: transparent;
  color: var(--app-muted);
}

.app-row input[readonly]:is(:hover, :focus) {
  border-color: var(--app-line);
  box-shadow: none;
}

.app-row :is(input:not([type="checkbox"]), select, textarea)[aria-invalid="true"],
.app-check:not(.app-row .app-check) input[aria-invalid="true"],
.app-row input:not([type="checkbox"]):user-invalid {
  border-color: var(--app-accent);
}

/* Checkbox groups flag the field name instead of each box. */
.app-row:has(.app-check input[aria-invalid="true"]) > .app-key {
  &,
  .app-req {
    color: var(--app-accent);
  }
}

.app-row :is(input, textarea)::placeholder {
  color: var(--app-faint);
}

.app-row textarea[name] {
  height: auto;
  min-height: 120px;
  padding: 10px 14px;
  line-height: 1.5;
  resize: vertical;
}

/* The native arrow ignores our text colour, so draw a chevron instead. */
.app-row select {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23e9eef0' stroke-opacity='.5' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  text-overflow: ellipsis;
}

.app-row select:invalid {
  color: var(--app-faint);
}

.app-row option {
  color: #0e1b20;
}

/* --- School combobox ------------------------------------------------------- */

.app-combobox {
  position: relative;
}

/* While open, input and list share one outlined box. */
.app-combobox:has([aria-expanded="true"]) {
  border: 1px solid var(--app-accent);
  border-radius: 10px;
  background: var(--app-panel);
  box-shadow: 0 0 0 3px var(--app-accent-soft);

  input,
  input:focus {
    border-color: transparent;
    box-shadow: none;
  }
}

.app-options {
  margin: 0;
  padding: 0 0 4px;
  list-style: none;

  li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    color: var(--app-muted);
    font-size: 0.92rem;
    cursor: pointer;
  }

  li[aria-selected="true"] {
    background: var(--app-active);
    color: var(--app-text);
  }

  li[aria-selected="true"]::after {
    content: "↵";
    color: var(--app-faint);
    font-family: var(--app-mono);
  }
}

/* --- Resume drop zone ------------------------------------------------------ */

.app-dropzone {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 44px;
  padding: 0 6px;
  box-sizing: border-box;
  border: 1px dashed var(--app-line-strong);
  border-radius: 10px;
  color: var(--app-muted);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease;

  /* Invisible but still focusable, so the label is the visible control. */
  input {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
  }
}

.app-dropzone:hover,
.app-dropzone.dragging {
  border-color: var(--app-accent);
  background: var(--app-accent-soft);
}

.app-dropzone:has(input:focus-visible) {
  outline: 2px solid var(--app-accent);
  outline-offset: 2px;
}

.app-dropzone.has-file .app-dropzone-text {
  color: var(--app-text);
}

.app-dropzone.has-error {
  border-color: var(--app-accent);
}

.app-dropzone.has-error .app-dropzone-text {
  color: var(--app-accent);
}

.app-dropzone-button {
  flex: none;
  padding: 6px 10px;
  border: 1px solid var(--app-accent);
  border-radius: 7px;
  color: var(--app-text);
  font-family: var(--app-mono);
  font-size: 0.78rem;
}

.app-dropzone-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* --- Checkboxes ------------------------------------------------------------ */

.app-check-note {
  display: block;
  color: var(--app-muted);
  font-size: 0.85rem;
}

.app-check {
  display: flex;
  align-items: start;
  gap: 14px;
  padding: 6px 0 6px var(--app-row-indent);
  line-height: 1.5;
  cursor: pointer;

  a {
    text-decoration-color: var(--app-accent);
    text-underline-offset: 3px;
  }

  input {
    flex: none;
    display: grid;
    place-content: center;
    width: 20px;
    height: 20px;
    margin: 2px 0 0;
    appearance: none;
    border: 1px solid var(--app-line-strong);
    border-radius: 5px;
    background: var(--app-panel);
    cursor: pointer;
  }

  input::after {
    content: "";
    width: 10px;
    height: 5px;
    border: solid #fff;
    border-width: 0 0 2px 2px;
    transform: translateY(-1px) rotate(-45deg);
    opacity: 0;
  }

  input:checked {
    border-color: var(--app-accent);
    background: var(--app-accent);
  }

  input:checked::after {
    opacity: 1;
  }
}

/* --- Dashboard values ------------------------------------------------------ */

.app-value {
  min-width: 0;
  color: var(--app-text);
}

.app-muted {
  color: var(--app-muted);
}

.app-prose {
  max-width: 62ch;
  margin: 0;
  padding: 6px 0 6px var(--app-row-indent);
  line-height: 1.55;
}

.app-row.app-row-top {
  align-items: start;
  padding-top: 8px;

  > .app-key {
    padding-top: 4px;
  }

  .app-check {
    padding-left: 0;
  }
}

.app-error {
  display: block;
  min-height: 0;
  margin: 0;
  padding: 8px 14px;
  border-left: 2px solid var(--app-accent);
  background: var(--app-accent-soft);
  color: var(--app-text);
}

.app-error.is-notice {
  border-left-color: var(--app-ok);
  background: rgba(95, 211, 154, 0.14);
}

.app-link {
  text-decoration: none;
}

.app-link:hover {
  color: var(--app-accent);
}

.app-status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-main .app-rsvp-form {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin: 0;
  text-align: left;
}

.app-rsvp {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.app-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--app-line-strong);
  border-radius: 999px;
  font-family: var(--app-mono);
  font-size: 0.8rem;
}

.app-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--app-faint);
}

.app-status.in-progress::before {
  background: #f2b84b;
}

.app-status:is(.submitted, .accepted)::before {
  background: var(--app-ok);
}

.app-status.waitlisted::before {
  background: #f2b84b;
}

.app-status:is(.rejected, .declined)::before {
  background: var(--app-accent);
}

.app-check-value {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--app-muted);
}

.app-tick {
  width: 1ch;
  font-family: var(--app-mono);
  color: var(--app-faint);
}

.app-check-value.done {
  color: var(--app-text);

  .app-tick {
    color: var(--app-ok);
  }
}

.app-countdown {
  font-family: var(--app-mono);
  font-size: 1.15rem;
}

/* --- Footer ---------------------------------------------------------------- */

/* Sticky so the submit button stays in reach on a long form. */
.app-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px var(--app-gutter);
  border-top: 1px solid var(--app-line);
  border-radius: 0 0 22px 22px;
  background: var(--app-window);

  form {
    margin: 0;
  }
}

.app-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin: 0;
  color: var(--app-muted);
  font-family: var(--app-mono);
  font-size: 0.78rem;

  kbd {
    display: inline-flex;
    align-items: center;
    height: 1.4em;
    line-height: 1;
    margin-right: 6px;
    vertical-align: middle;
    color: var(--app-text);
    font-family: var(--app-mono), "Apple Symbols", "Segoe UI Symbol", "DejaVu Sans", sans-serif;
  }

  kbd + kbd {
    margin-left: 0;
  }

  kbd[data-mod] {
    font-size: 1.25em;
  }

  .app-key-icon {
    width: 1.1em;
    height: 1.1em;
  }
}

.app-segmented > .app-button {
  flex: 1;
  justify-content: center;
}

.app-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  box-sizing: border-box;
  border: 1px solid var(--app-line-strong);
  border-radius: 10px;
  background: var(--app-active);
  color: var(--app-text);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.app-button:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
}

.app-button.primary {
  border-color: transparent;
  background: #de2839;
  color: #fff;
}

.app-button.primary:hover {
  background: #c91f30;
}

.app-button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.app-button.danger {
  height: 36px;
  border-color: var(--app-line);
  background: transparent;
  color: var(--app-muted);
  font-weight: 500;
}

.app-button.danger:hover {
  border-color: var(--app-accent);
  background: var(--app-accent-soft);
  color: var(--app-text);
}

.app-row > :is(.app-button, .discord-button).wide,
.app-row > .discord-button {
  grid-column: 2;
  width: 100%;
  justify-content: center;
}

.app-page .discord-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 42px;
  padding: 0 18px;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #5865f2;
  color: #fff;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease;

  img {
    width: 24px;
    height: 24px;
  }
}

.app-page .discord-button:hover {
  background: #4752c4;
}

.app-page .discord-button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.app-button:disabled {
  border-color: var(--app-line-strong);
  background: var(--app-active);
  color: var(--app-muted);
  cursor: not-allowed;
}

/* --- Narrow screens ---------------------------------------------------------
   Sidebar turns into a row of tabs above the content and labels sit above
   their inputs. Keeps a 16px gutter. */

@media (max-width: 760px) {
  .app-page {
    --app-gutter: 16px;
    padding: 16px;
  }

  .app-window {
    border-radius: 18px;
  }

  .app-titlebar {
    border-radius: 18px 18px 0 0;
  }

  /* Drop the first crumb so the current page name isn't cut off. */
  .app-crumb-home {
    display: none;
  }

  /* No room beside the breadcrumb; the tabs below carry the same counts. */
  .app-titlebar-meta {
    display: none;
  }

  .app-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--app-line);
  }

  .app-sidebar-inner {
    gap: 14px;
    padding: 18px 12px 14px;

    h1 {
      font-size: 1.3rem;
    }
  }

  .app-steps {
    flex-direction: row;
    overflow-x: auto;

    a {
      flex: 1 0 auto;
      padding: 10px 12px;
    }
  }

  .app-note:not(.app-note-keep) {
    display: none;
  }

  .app-row > :is(.app-button, .discord-button).wide,
  .app-row > .discord-button {
    grid-column: 1;
    height: 48px;
  }

  .app-page {
    --app-row-indent: 12px;
  }

  .app-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .app-footer {
    border-radius: 0 0 18px 18px;
  }

  /* Shortcut hints don't apply on touch screens. */
  .app-keys:has(kbd) {
    display: none;
  }

  .app-footer > .app-button,
  .app-footer form,
  .app-footer form .app-button {
    width: 100%;
    justify-content: center;
  }
}

.app-section [hidden] {
  display: none;
}

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