/* ==========================================================================
   Stormsaver — login.css
   Page-specific styles for login.html. Requires brand.css to be loaded first
   (uses --brand-teal etc.).
   ========================================================================== */
/* LIGHT MODE (default) — pale surfaces, navy ink, teal highlight */
    :root {
      --bg:        #EDF3F5;
      --panel:     #ffffff;
      --border:    #C3D3D8;
      --accent:    #002A66;   /* navy: contrast-safe for links/buttons on light */
      --accent2:   #001B45;   /* darker navy hover */
      --text:      #002A66;
      --text-dim:  #5A7386;
      --error:     #d9534f;
      --success:   #2a9d6e;
      --input-bg:  #ffffff;
    }

    /* DARK MODE — navy field (matches brand wave art), teal highlight */
    body.dark {
      --bg:        #002A66;
      --panel:     #0A3A70;
      --border:    #1C4A86;
      --accent:    #4FA6B8;   /* teal: pops on navy */
      --accent2:   #3B8296;   /* deeper teal hover */
      --text:      #EAF2F6;
      --text-dim:  #8FB2C4;
      --error:     #ff6b6b;
      --success:   #3fd39b;
      --input-bg:  #062A57;
    }

    html, body {
      height: 100%;
      background: var(--bg);
      color: var(--text);
      font-family: 'Barlow', sans-serif;
      font-weight: 300;
      overflow: hidden;
      transition: background-color 0.25s ease, color 0.2s ease;
    }

    /* ── Brand wave background (inline SVG, theme-tinted via currentColor) ── */
    .brand-wave {
      position: fixed; inset: 0; z-index: 0;
      pointer-events: none; overflow: hidden;
      color: #177e95;                      /* light theme: official deep-teal wave */
      opacity: 0.85;
      transition: color 0.25s ease, opacity 0.25s ease;
    }
    body.dark .brand-wave {
      color: #4FA6B8;                      /* dark theme: official teal wave on navy */
      opacity: 0.9;
    }
    .brand-wave .wave-svg {
      position: absolute; inset: 0;
      width: 100%; height: 100%;
    }

    /* ── Layout ── */
    .page {
      position: relative;
      height: 100vh;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 0;
      z-index: 1;
    }

    /* ── Top bar ── */
    .login-topbar {
      position: fixed; top: 0; left: 0; right: 0;
      height: 56px; display: flex; align-items: center;
      padding: 0 20px; gap: 12px; z-index: 100;
    }

    /* ── Theme toggle button ── */
    .theme-toggle {
      background: var(--panel);
      border: 1px solid var(--border);
      border-radius: 48px;
      width: 38px; height: 38px;
      display: flex; align-items: center; justify-content: center;
      cursor: pointer; flex-shrink: 0;
      transition: all 0.2s ease;
    }
    .theme-toggle:hover { transform: scale(1.05); border-color: var(--accent); }
    .theme-toggle svg { width: 20px; height: 20px; stroke: var(--text); fill: none; stroke-width: 1.8; transition: stroke 0.2s; }
    body.dark .theme-toggle .sun-icon { display: block; }
    body.dark .theme-toggle .moon-icon { display: none; }
    body:not(.dark) .theme-toggle .sun-icon { display: none; }
    body:not(.dark) .theme-toggle .moon-icon { display: block; }

    .login-logo img { height: 34px; width: auto; display: block; }

    /* Brand header */
    .brand {
      display: flex;
      flex-direction: column;
      align-items: center;
      margin-bottom: 2.5rem;
      animation: fadeDown 0.6s ease both;
    }

    .brand-logo-img {
      width: 220px;
      height: auto;
      display: block;
    }

    /* Invert logo colours in dark mode so it stays visible */
    body.dark .brand-logo-img {
      filter: brightness(0) invert(1);
    }

    /* Card */
    .card {
      width: 100%;
      max-width: 400px;
      background: var(--panel);
      border: 1px solid var(--border);
      border-top: 2px solid var(--brand-teal);
      padding: 2.5rem 2.5rem 2rem;
      position: relative;
      animation: fadeUp 0.6s ease 0.1s both;
      transition: background 0.2s, border-color 0.2s;
    }

    /* corner marks */
    .card::before, .card::after {
      content: '';
      position: absolute;
      width: 12px; height: 12px;
      border-color: var(--brand-teal);
      border-style: solid;
      opacity: 0.6;
      transition: border-color 0.2s;
    }
    .card::before { bottom: -1px; left: -1px; border-width: 0 0 1px 1px; }
    .card::after  { bottom: -1px; right: -1px; border-width: 0 1px 1px 0; }

    .card-title {
      font-family: 'Barlow Condensed', sans-serif;
      font-size: 0.7rem;
      font-weight: 600;
      letter-spacing: 0.2em;
      text-transform: uppercase;
      color: var(--text-dim);
      margin-bottom: 1.8rem;
      display: flex;
      align-items: center;
      gap: 0.6rem;
    }

    .card-title::after {
      content: '';
      flex: 1;
      height: 1px;
      background: var(--border);
    }

    /* Form fields */
    .field {
      margin-bottom: 1.2rem;
    }

    label {
      display: block;
      font-size: 0.68rem;
      font-weight: 500;
      letter-spacing: 0.16em;
      text-transform: uppercase;
      color: var(--text-dim);
      margin-bottom: 0.45rem;
    }

    input {
      width: 100%;
      background: var(--input-bg);
      border: 1px solid var(--border);
      color: var(--text);
      font-family: 'Barlow', sans-serif;
      font-size: 0.95rem;
      font-weight: 400;
      padding: 0.65rem 0.85rem;
      outline: none;
      transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
      -webkit-appearance: none;
    }

    input:focus {
      border-color: var(--brand-teal);
      box-shadow: 0 0 0 2px rgba(79,166,184,0.28);
    }

    input::placeholder { color: var(--text-dim); opacity: 0.5; }

    /* Error message */
    .error-msg {
      display: none;
      font-size: 0.78rem;
      color: var(--error);
      background: rgba(217,83,79,0.08);
      border: 1px solid rgba(217,83,79,0.25);
      padding: 0.55rem 0.8rem;
      margin-bottom: 1.2rem;
      letter-spacing: 0.02em;
    }

    .error-msg.visible { display: block; }

    /* Button */
    button[type="submit"] {
      width: 100%;
      margin-top: 0.4rem;
      background: var(--accent);
      color: #ffffff;
      border: none;
      font-family: 'Barlow Condensed', sans-serif;
      font-size: 0.95rem;
      font-weight: 700;
      letter-spacing: 0.18em;
      text-transform: uppercase;
      padding: 0.8rem;
      cursor: pointer;
      position: relative;
      overflow: hidden;
      transition: background 0.2s, transform 0.1s, color 0.2s;
    }
    body.dark button[type="submit"] {
      color: #000;
    }
    body:not(.dark) button[type="submit"] {
      color: white;
    }

    button[type="submit"]:hover  { background: var(--accent2); filter: brightness(1.05); }
    button[type="submit"]:active { transform: scale(0.99); }

    button[type="submit"]:disabled {
      background: var(--text-dim);
      cursor: not-allowed;
      opacity: 0.7;
    }

    /* spinner inside button */
    .btn-spinner {
      display: none;
      width: 16px; height: 16px;
      border: 2px solid rgba(0,0,0,0.3);
      border-top-color: currentColor;
      border-radius: 50%;
      animation: spin 0.7s linear infinite;
      margin: 0 auto;
    }

    .btn-text { display: block; }

    button.loading .btn-text    { display: none; }
    button.loading .btn-spinner { display: block; }

    /* Footer note */
    .footer-note {
      margin-top: 2rem;
      font-size: 0.68rem;
      letter-spacing: 0.1em;
      color: var(--text-dim);
      text-align: center;
      animation: fadeUp 0.6s ease 0.25s both;
    }

    /* Animations */
    @keyframes fadeDown {
      from { opacity: 0; transform: translateY(-16px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    @keyframes fadeUp {
      from { opacity: 0; transform: translateY(16px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    @keyframes spin {
      to { transform: rotate(360deg); }
    }

    /* Forgot password link */
    .forgot-link {
      display: block;
      text-align: right;
      margin-top: 0.5rem;
      font-size: 0.72rem;
      letter-spacing: 0.08em;
      color: var(--accent);
      text-decoration: none;
      cursor: pointer;
      transition: opacity 0.2s;
    }
    .forgot-link:hover { opacity: 0.75; }

    /* Reset modal overlay */
    .modal-overlay {
      display: none;
      position: fixed; inset: 0;
      background: rgba(0,0,0,0.55);
      z-index: 200;
      align-items: center;
      justify-content: center;
    }
    .modal-overlay.open { display: flex; }

    .modal {
      background: var(--panel);
      border: 1px solid var(--border);
      border-top: 2px solid var(--brand-teal);
      width: 100%;
      max-width: 380px;
      padding: 2rem 2rem 1.6rem;
      position: relative;
      animation: fadeUp 0.25s ease both;
    }

    .modal-title {
      font-family: 'Barlow Condensed', sans-serif;
      font-size: 0.7rem;
      font-weight: 600;
      letter-spacing: 0.2em;
      text-transform: uppercase;
      color: var(--text-dim);
      margin-bottom: 0.6rem;
      display: flex; align-items: center; gap: 0.6rem;
    }
    .modal-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

    .modal-desc {
      font-size: 0.82rem;
      color: var(--text-dim);
      margin-bottom: 1.2rem;
      line-height: 1.5;
    }

    .modal-close {
      position: absolute; top: 0.8rem; right: 0.9rem;
      background: none; border: none; cursor: pointer;
      color: var(--text-dim); font-size: 1.1rem; line-height: 1;
      padding: 0.2rem 0.4rem;
      transition: color 0.2s;
    }
    .modal-close:hover { color: var(--text); }

    .modal-step { display: none; }
    .modal-step.active { display: block; }

    .success-msg {
      display: none;
      font-size: 0.78rem;
      color: var(--success);
      background: rgba(42,157,110,0.08);
      border: 1px solid rgba(42,157,110,0.25);
      padding: 0.55rem 0.8rem;
      margin-bottom: 1rem;
    }
    .success-msg.visible { display: block; }

    .modal-error {
      display: none;
      font-size: 0.78rem;
      color: var(--error);
      background: rgba(217,83,79,0.08);
      border: 1px solid rgba(217,83,79,0.25);
      padding: 0.55rem 0.8rem;
      margin-bottom: 1rem;
    }
    .modal-error.visible { display: block; }

    .modal .field { margin-bottom: 1rem; }

    .modal-btn {
      width: 100%;
      background: var(--accent);
      color: #fff;
      border: none;
      font-family: 'Barlow Condensed', sans-serif;
      font-size: 0.92rem;
      font-weight: 700;
      letter-spacing: 0.16em;
      text-transform: uppercase;
      padding: 0.75rem;
      cursor: pointer;
      transition: background 0.2s, opacity 0.2s;
      margin-top: 0.2rem;
    }
    body.dark .modal-btn { color: #000; }
    .modal-btn:hover { background: var(--accent2); }
    .modal-btn:disabled { opacity: 0.6; cursor: not-allowed; }

    .code-hint {
      font-size: 0.68rem;
      color: var(--text-dim);
      margin-top: 0.4rem;
      letter-spacing: 0.04em;
    }

    /* Responsive */
    @media (max-width: 480px) {
      .card { padding: 1.8rem 1.5rem 1.5rem; margin: 0 16px; }
      .theme-toggle { top: 16px; right: 16px; width: 40px; height: 40px; }
    }
