/* Visual identity for the two pre-game screens (login, character-select) —
   the seal, wordmark, tagline, form/list chrome, and entry points like the
   news teaser and "New here?" modal. Reads the same --bg/--fg/--accent/
   --border/--panel-bg tokens as the rest of the client, so both screens
   re-theme for free if a theme is ever chosen before login. */

#app {
  border: 1px solid var(--accent, #7fdbca);
}

/* No justify-content: center — centering instead comes from the
   margin-top: auto / margin-bottom: auto pair on the hero and content below.
   justify-content: center clips the top of overflowing content with no way
   to scroll to it, since the scroll container's top position is already
   the "centered" position; auto margins center the same way when content
   fits, but collapse to 0 and allow normal top-down scrolling once it
   doesn't. */
#login-screen:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 0;
}

#login-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  margin-top: auto;
  margin-bottom: 2rem;
}


#wordmark {
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(1.75rem, 6vw, 2.5rem);
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg, #d0d0d0);
  text-shadow: 0 0 12px var(--accent, #7fdbca);
}

/* Runic subset only (U+16A0-16F8) — the login-hero tagline is the only thing
   on either pre-game screen that renders in it. */
@font-face {
  font-family: 'Noto Sans Runic';
  src: url('../fonts/NotoSansRunic-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

#tagline {
  margin: 0;
  font-family: 'Noto Sans Runic', 'JetBrains Mono', monospace;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  color: var(--dim, #6b6b6b);
}

#login-links {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1.25rem;
  width: 100%;
  max-width: 300px; /* matches the login form's own max-width so the divider lines up with it rather than stretching wider */
  margin: 0 auto;
  margin-bottom: auto;
  font-size: 0.85rem;
}

/* A text link, not a button-chrome button — sits next to plain prose (the
   news teaser, or nothing) and needs to read as the same weight of thing,
   not compete with the filled submit buttons below it. */
#show-about-mud,
#character-logout {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent, #7fdbca);
  text-decoration: none;
  cursor: pointer;
}

#show-about-mud:hover,
#show-about-mud:focus-visible,
#character-logout:hover,
#character-logout:focus-visible {
  color: var(--fg, #d0d0d0);
}

#news-teaser {
  margin: 0;
  color: var(--dim, #6b6b6b);
}

.news-label {
  color: var(--accent, #7fdbca);
}

#login-forms {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* Full input/button chrome, scoped to the login screen only — the rest of
   the client isn't part of this treatment and keeps its own styling. */
#login-screen input {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px; /* the threshold below which iOS Safari auto-zooms an input on focus */
  padding: 0.5rem 0.6rem;
  background: var(--panel-bg, #0e1211);
  border: 1px solid var(--border, #333333);
  border-radius: 2px;
  color: var(--fg, #d0d0d0);
  box-sizing: border-box;
}

#login-screen input:focus {
  outline: none;
  border-color: var(--accent, #7fdbca);
  background: var(--panel-bg-focus, #14302c);
}

#login-screen button {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  padding: 0.5rem 0.6rem;
  background: transparent;
  border: 1px solid var(--border, #333333);
  border-radius: 2px;
  color: var(--fg, #d0d0d0);
  cursor: pointer;
}

#login-screen button:hover,
#login-screen button:focus-visible {
  border-color: var(--accent, #7fdbca);
  color: var(--accent, #7fdbca);
  outline: none;
}

/* The primary action in the form, visually distinct from the secondary
   buttons beside it. */
#login-form button[type='submit'] {
  background: var(--accent, #7fdbca);
  border-color: var(--accent, #7fdbca);
  color: var(--bg, #0b0b0b);
  font-weight: 700;
}

#login-form button[type='submit']:hover,
#login-form button[type='submit']:focus-visible {
  filter: brightness(1.1);
  color: var(--bg, #0b0b0b);
}

/* text-align: left overrides the screen's own centered text — centered
   prose reads fine for a one-line label, but centering the multi-line list
   below would make each line's ragged edge jump left and right
   unpredictably, harder to read than a consistent left edge. */
#register-rules {
  width: 100%;
  font-size: 0.85rem;
  color: var(--dim, #6b6b6b);
  text-align: left;
}

#register-rules ol {
  margin: 0 0 0.5rem;
  padding-left: 1.2rem;
}

#register-rules ol li {
  margin-bottom: 0.3rem;
}

#register-rules-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

/* Custom checkbox skin — appearance: none strips native browser chrome so
   it can be drawn with the same border/panel-bg/accent tokens as the rest
   of the form. The checkmark is a rotated two-sided box, a classic
   CSS-only checkmark, rather than an image, keeping this dependency-free. */
#register-rules-checkbox-label input[type='checkbox'] {
  appearance: none;
  flex: 0 0 auto;
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  background: var(--panel-bg, #0e1211);
  border: 1px solid var(--border, #333333);
  border-radius: 2px;
  cursor: pointer;
}

#register-rules-checkbox-label input[type='checkbox']:hover {
  border-color: var(--accent, #7fdbca);
}

#register-rules-checkbox-label input[type='checkbox']:focus-visible {
  outline: none;
  border-color: var(--accent, #7fdbca);
  background: var(--panel-bg-focus, #14302c);
}

#register-rules-checkbox-label input[type='checkbox']:checked {
  display: grid;
  place-content: center;
  background: var(--accent, #7fdbca);
  border-color: var(--accent, #7fdbca);
}

#register-rules-checkbox-label input[type='checkbox']:checked::before {
  content: '';
  width: 0.3rem;
  height: 0.55rem;
  border: solid var(--bg, #0b0b0b);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

/* Native <dialog> — its own top-layer promotion doesn't detach it from the
   document's custom-property inheritance, so --bg/--fg/etc. still resolve
   normally despite showModal()'s special paint order. Chosen over a
   hand-rolled modal for the free focus trap and Escape-to-close; only the
   backdrop-click-to-close behavior and this visual skin are added by
   hand. */
#about-mud-modal {
  position: relative;
  max-width: min(90vw, 30rem);
  max-height: 85vh;
  overflow-y: auto;
  background: var(--panel-bg, #0e1211);
  color: var(--fg, #d0d0d0);
  border: 1px solid var(--border, #333333);
  border-radius: 2px;
  padding: 1.5rem;
  font-family: 'JetBrains Mono', monospace;
}

#about-mud-modal::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

#about-mud-modal h2 {
  margin: 1.25rem 0 0.4rem;
  font-size: 1rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent, #7fdbca);
}

#about-mud-modal h2:first-of-type {
  margin-top: 0;
}

#about-mud-modal p,
#about-mud-modal li {
  line-height: 1.5;
  font-size: 0.9rem;
}

#about-mud-modal ul {
  margin: 0;
  padding-left: 1.2rem;
}

/* Shared layout for the four non-landing auth screens: register and the
   three account-recovery screens. Same centered-column shape as the login
   and character screens, so moving between screens doesn't jar visually.
   None of these carry a hero logo/wordmark/tagline — only the landing
   screen does. */
/* No justify-content: center — auto margins (margin-top: auto on each hero
   below, margin-bottom: auto on whichever content div is showing) center
   the same way while content fits, but collapse to 0 and allow normal
   top-down scrolling once it overflows, unlike justify-content: center
   which would clip the top with no way to scroll to it. Only one of a
   screen's alternate content divs is ever unhidden at a time, so giving
   all of them the rule is harmless — the hidden ones aren't in flow
   either way. */
#register-screen:not([hidden]),
#forgot-password-screen:not([hidden]),
#reset-password-screen:not([hidden]),
#verify-email-screen:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 0;
  text-align: center;
}

#register-hero,
#forgot-password-hero,
#reset-password-hero,
#verify-email-hero {
  margin-top: auto;
}

#register-form,
#forgot-password-form,
#reset-password-form,
#reset-password-success,
#verify-email-success,
#verify-email-failure {
  margin-bottom: auto;
}

#register-hero h1,
#forgot-password-hero h1,
#reset-password-hero h1,
#verify-email-hero h1 {
  margin: 0 0 1.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg, #d0d0d0);
}

#register-form,
#forgot-password-form,
#reset-password-form:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
  max-width: 300px;
}

/* :not([type='checkbox']) — #register-form is the only one of this group
   with a checkbox (the rules-agreement checkbox); its own rule below gives
   it a custom skin instead of this text-input treatment. */
#register-form input:not([type='checkbox']),
#forgot-password-form input,
#reset-password-form input {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  padding: 0.5rem 0.6rem;
  background: var(--panel-bg, #0e1211);
  border: 1px solid var(--border, #333333);
  border-radius: 2px;
  color: var(--fg, #d0d0d0);
  box-sizing: border-box;
}

#register-form input:focus,
#forgot-password-form input:focus,
#reset-password-form input:focus {
  outline: none;
  border-color: var(--accent, #7fdbca);
  background: var(--panel-bg-focus, #14302c);
}

#register-form button,
#forgot-password-form button,
#reset-password-form button,
#reset-password-success button,
#verify-email-success button,
#verify-email-failure button {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  padding: 0.5rem 0.6rem;
  background: transparent;
  border: 1px solid var(--border, #333333);
  border-radius: 2px;
  color: var(--fg, #d0d0d0);
  cursor: pointer;
}

#register-form button:hover,
#register-form button:focus-visible,
#forgot-password-form button:hover,
#forgot-password-form button:focus-visible,
#reset-password-form button:hover,
#reset-password-form button:focus-visible,
#reset-password-success button:hover,
#reset-password-success button:focus-visible,
#verify-email-success button:hover,
#verify-email-success button:focus-visible,
#verify-email-failure button:hover,
#verify-email-failure button:focus-visible {
  border-color: var(--accent, #7fdbca);
  color: var(--accent, #7fdbca);
  outline: none;
}

#register-form button[type='submit'],
#forgot-password-form button[type='submit'],
#reset-password-form button[type='submit'] {
  background: var(--accent, #7fdbca);
  border-color: var(--accent, #7fdbca);
  color: var(--bg, #0b0b0b);
  font-weight: 700;
}

#register-form button[type='submit']:hover,
#register-form button[type='submit']:focus-visible,
#forgot-password-form button[type='submit']:hover,
#forgot-password-form button[type='submit']:focus-visible,
#reset-password-form button[type='submit']:hover,
#reset-password-form button[type='submit']:focus-visible {
  filter: brightness(1.1);
  color: var(--bg, #0b0b0b);
}

.forgot-password-notice {
  margin: 0;
  font-size: 0.85rem;
  color: var(--dim, #6b6b6b);
}

.forgot-password-notice:empty {
  display: none;
}

#reset-password-success:not([hidden]),
#verify-email-success:not([hidden]),
#verify-email-failure:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

/* The character screen's verification nag — less prominent than a
   .form-error since this isn't a failure state, but still visually
   distinct from the surrounding dim, muted text. */
#verification-banner:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  max-width: 300px;
  margin-bottom: 1rem;
  padding: 0.6rem;
  border: 1px solid var(--border, #333333);
  border-radius: 2px;
  font-size: 0.85rem;
  text-align: center;
  color: var(--dim, #6b6b6b);
}

#verification-banner-resend {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
  background: transparent;
  border: 1px solid var(--border, #333333);
  border-radius: 2px;
  color: var(--accent, #7fdbca);
  cursor: pointer;
}

#verification-banner-resend:hover,
#verification-banner-resend:focus-visible {
  border-color: var(--accent, #7fdbca);
  color: var(--fg, #d0d0d0);
  outline: none;
}

/* No justify-content: center — margin-top: auto on the hero and
   margin-bottom: auto on the panel below center the same way while content
   fits, but collapse to 0 and allow normal scrolling once it overflows. */
#character-screen:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 0;
}

#character-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-top: auto;
  margin-bottom: 1.5rem;
}

#character-heading {
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg, #d0d0d0);
}

#character-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 300px;
  margin-bottom: auto;
}

#character-screen-empty,
#character-screen-notice {
  margin: 0;
  font-size: 0.85rem;
  text-align: center;
  color: var(--dim, #6b6b6b);
}

#character-screen-notice:empty {
  display: none;
}

#character-list {
  margin: 0;
  padding: 0;
}

#character-list li {
  flex-wrap: wrap;
  border-top: 1px solid var(--border, #333333);
}

#character-list li:first-child {
  border-top: none;
}

#character-list li:hover,
#character-list li:focus-within {
  background: var(--panel-bg-focus, #14302c);
}

.character-select-button {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 0.35em;
  padding: 0.6rem 0.5rem;
  background: transparent;
  border: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  text-align: left;
  color: var(--fg, #d0d0d0);
  cursor: pointer;
}

.character-select-button .character-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-select-button .character-meta {
  flex: 0 0 auto;
  color: var(--dim, #6b6b6b);
  font-weight: 400;
}

.character-select-button:hover,
.character-select-button:focus-visible {
  color: var(--accent, #7fdbca);
  outline: none;
}

.character-delete-button {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border, #333333);
  border-radius: 2px;
  color: var(--dim, #6b6b6b);
  cursor: pointer;
}

.character-delete-button:hover,
.character-delete-button:focus-visible {
  border-color: var(--hp-critical, #e0685c);
  color: var(--hp-critical, #e0685c);
  outline: none;
}

/* flex-basis: 100% drops this onto its own line below the name/delete
   buttons, since the parent list item is already display: flex with
   flex-wrap: wrap added here — a full-width child wraps onto a new line
   instead of squeezing into the row's remaining space. */
.delete-confirm:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-basis: 100%;
  margin: 0.5rem 0 0.75rem;
  padding: 0.6rem;
  border: 1px solid var(--hp-critical, #e0685c);
  border-radius: 2px;
  background: var(--panel-bg, #0e1211);
}

.delete-confirm-input {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  padding: 0.5rem 0.6rem;
  background: var(--bg, #0b0b0b);
  border: 1px solid var(--border, #333333);
  border-radius: 2px;
  color: var(--fg, #d0d0d0);
  box-sizing: border-box;
}

.delete-confirm-input:focus {
  outline: none;
  border-color: var(--hp-critical, #e0685c);
}

.delete-confirm button {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  padding: 0.45rem 0.6rem;
  background: transparent;
  border: 1px solid var(--border, #333333);
  border-radius: 2px;
  color: var(--fg, #d0d0d0);
  cursor: pointer;
}

.delete-confirm button:hover,
.delete-confirm button:focus-visible {
  border-color: var(--fg, #d0d0d0);
  outline: none;
}

/* The destructive action in the confirm box — filled in --hp-critical
   rather than --accent, so deleting reads as dangerous, not as the
   screen's ordinary primary action. */
.delete-confirm button[data-action='confirm-delete'] {
  background: var(--hp-critical, #e0685c);
  border-color: var(--hp-critical, #e0685c);
  color: var(--bg, #0b0b0b);
  font-weight: 700;
}

.delete-confirm button[data-action='confirm-delete']:hover,
.delete-confirm button[data-action='confirm-delete']:focus-visible {
  filter: brightness(1.1);
  color: var(--bg, #0b0b0b);
}

#character-create-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 1rem 0 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border, #333333);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent, #7fdbca);
}

#character-slot-count {
  letter-spacing: normal;
  text-transform: none;
  color: var(--dim, #6b6b6b);
}

/* Scoped to elements inside a <form>, since the character list's own
   buttons live outside any <form> and need different styling. */
#character-screen form input,
#character-screen form select {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  padding: 0.5rem 0.6rem;
  background: var(--panel-bg, #0e1211);
  border: 1px solid var(--border, #333333);
  border-radius: 2px;
  color: var(--fg, #d0d0d0);
  box-sizing: border-box;
}

#character-screen form input:focus,
#character-screen form select:focus {
  outline: none;
  border-color: var(--accent, #7fdbca);
  background: var(--panel-bg-focus, #14302c);
}

#character-screen form button {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  padding: 0.5rem 0.6rem;
  background: transparent;
  border: 1px solid var(--border, #333333);
  border-radius: 2px;
  color: var(--fg, #d0d0d0);
  cursor: pointer;
}

#character-screen form button:hover,
#character-screen form button:focus-visible {
  border-color: var(--accent, #7fdbca);
  color: var(--accent, #7fdbca);
  outline: none;
}

#character-create-form button[type='submit'] {
  background: var(--accent, #7fdbca);
  border-color: var(--accent, #7fdbca);
  color: var(--bg, #0b0b0b);
  font-weight: 700;
}

#character-create-form button[type='submit']:hover,
#character-create-form button[type='submit']:focus-visible {
  filter: brightness(1.1);
  color: var(--bg, #0b0b0b);
}

#character-links {
  margin-top: 1.5rem;
  font-size: 0.85rem;
}

@media (max-width: 480px) {
  #login-links {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
  }

  #about-mud-modal {
    padding: 1rem;
  }
}
