/*
  Palette derived from the logo mint (#84DDD1).

  That mint is only 1.59:1 against white, so it can never carry white text or act as a
  button fill. It's used here as brand trim — on dark surfaces, for active states, and
  as tint backgrounds — while the darker teals do the interactive work:
    --accent      #1F7A6E on white = 5.2:1  (AA for normal text)
    --brand-900   behind mint text  = 7.0:1
*/
:root {
    --brand-mint: #84ddd1;
    --brand-mint-soft: #eaf9f6;
    --brand-mint-200: #c3eee7;
    --brand-600: #2a9d8c;
    --brand-700: #1f7a6e;
    --brand-800: #145a51;
    --brand-900: #0e4139;

    --bg: #f4faf9;
    --surface: #ffffff;
    --border: #dbe6e4;
    --text: #16241f;
    --text-muted: #5a6b67;

    --accent: var(--brand-700);
    --accent-dark: var(--brand-800);

    --danger: #b3261e;
    --danger-bg: #fdecea;
    --success: #1b5e20;
    --success-bg: #e8f5e9;

    --radius: 10px;
    --shadow: 0 1px 2px rgb(14 65 57 / 6%), 0 4px 12px rgb(14 65 57 / 6%);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

h1 { font-size: 1.75rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .25rem; }
a { color: var(--accent); }

/* ---------- Shell ---------- */

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* The logo's "kids" is knocked out of a white disc — it's transparent, not painted.
   On a light header it disappears entirely, so this bar has to stay dark. */
.app-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: .7rem 1.25rem;
    background: linear-gradient(180deg, var(--brand-800), var(--brand-900));
    border-bottom: 3px solid var(--brand-mint);
    flex-wrap: wrap;
}

.brand { display: flex; align-items: center; text-decoration: none; }
.brand-logo { display: block; height: 38px; width: auto; }

/* Holds the nav and the user area, so a phone can fold both behind the menu button. */
.app-menu { display: flex; align-items: center; gap: 1.5rem; flex: 1; }

.app-nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }

.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    padding: 0;
    border-radius: 8px;
    border: 1px solid rgb(255 255 255 / 28%);
    background: rgb(255 255 255 / 10%);
    color: #fff;
    cursor: pointer;
}

.nav-toggle:hover { background: rgb(255 255 255 / 20%); }
.nav-toggle:focus-visible { outline: 2px solid var(--brand-mint); outline-offset: 2px; }

.nav-link {
    padding: .45rem .8rem;
    border-radius: 8px;
    text-decoration: none;
    color: rgb(255 255 255 / 78%);
    font-weight: 550;
}

.nav-link:hover { background: rgb(255 255 255 / 12%); color: #fff; }
.nav-link.active { background: var(--brand-mint); color: var(--brand-900); font-weight: 650; }

.app-user { display: flex; align-items: center; gap: .75rem; }
.user-name { color: rgb(255 255 255 / 78%); font-size: .9rem; }

.app-user .btn {
    color: #fff;
    background: rgb(255 255 255 / 10%);
    border-color: rgb(255 255 255 / 28%);
}

.app-user .btn:hover:not(:disabled) { background: rgb(255 255 255 / 20%); color: #fff; }
.app-user .btn:focus-visible { outline-color: var(--brand-mint); }

@media (max-width: 640px) {
    .app-header { justify-content: space-between; padding: .55rem .9rem; }
    .brand-logo { height: 32px; }
    .nav-toggle { display: inline-flex; }

    .app-menu {
        display: none;
        flex-basis: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: .75rem;
        padding-bottom: .25rem;
    }

    .menu-open .app-menu { display: flex; }
    .app-nav { flex-direction: column; }
    .nav-link { padding: .7rem .8rem; }

    .app-user {
        justify-content: space-between;
        padding-top: .75rem;
        border-top: 1px solid rgb(255 255 255 / 15%);
    }
}

.app-main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 1.75rem 1.25rem; }

/* ---------- Auth pages ---------- */

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background: linear-gradient(160deg, var(--brand-800), var(--brand-900) 70%);
}

.auth-main { width: 100%; max-width: 25rem; }

/* ---------- Build stamp ---------- */

/* Deliberately quiet and out of the way, but present on every screen: it's only ever
   looked at when someone is asking "is this the build I just shipped?" */
.app-foot {
    padding: 1rem 1.25rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
}

/* On the login screen the ground is dark teal, so the muted grey used elsewhere
   would sink into it. */
.auth-foot-version { margin-top: 1.5rem; text-align: center; color: var(--brand-mint-200); }

.app-version { font-size: .75rem; letter-spacing: .02em; font-variant-numeric: tabular-nums; }

.auth-logo {
    display: block;
    width: 15rem;
    max-width: 80%;
    height: auto;
    margin: 0 auto 1.75rem;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgb(14 65 57 / 28%);
    padding: 2rem;
}

.auth-sub { color: var(--text-muted); margin: 0 0 1.5rem; }
.auth-foot { margin: 1.25rem 0 0; text-align: center; font-size: .9rem; }

/* ---------- Forms ---------- */

.field { display: block; margin-bottom: 1rem; }
.field-label { display: block; font-weight: 550; font-size: .9rem; margin-bottom: .3rem; }
.field-hint { color: var(--text-muted); font-size: .85rem; margin: -.5rem 0 1rem; }

.input {
    width: 100%;
    padding: .6rem .7rem;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.input:focus-visible {
    outline: 2px solid var(--brand-600);
    outline-offset: 1px;
    border-color: var(--brand-600);
}

.input:disabled { background: var(--bg); color: var(--text-muted); }

.validation-message { display: block; color: var(--danger); font-size: .85rem; margin-top: .3rem; }

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .6rem 1rem;
    font: inherit;
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover:not(:disabled) { background: var(--brand-mint-soft); border-color: var(--brand-mint-200); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }

.btn-primary:hover:not(:disabled) {
    background: var(--brand-800);
    border-color: var(--brand-800);
    color: #fff;
}

/* For the confirming button in a destructive dialog — never for the button that opens
   one, or every list of actions turns red. */
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }

.btn-danger:hover:not(:disabled) { background: #8f1e17; border-color: #8f1e17; color: #fff; }
.btn-danger:focus-visible { outline-color: var(--danger); }

.btn-quiet { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn-quiet:hover:not(:disabled) { background: var(--brand-mint-soft); color: var(--text); }

.btn-block { width: 100%; }

/* ---------- Notices ---------- */

.notice { padding: .75rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .92rem; }
.notice-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #f5c6c2; }
.notice-success { background: var(--success-bg); color: var(--success); border: 1px solid #c3e6c6; }

/* ---------- Cards ---------- */

.lede { color: var(--text-muted); margin: 0 0 1.5rem; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 1rem;
}

.card {
    display: block;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--brand-mint);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
}

.card:hover { border-color: var(--brand-600); border-top-color: var(--brand-600); }
.card h2 { color: var(--brand-800); }
.card p { color: var(--text-muted); margin: 0; font-size: .92rem; }

/* ---------- Boot splash ---------- */
/* Lives inside #app and is replaced the moment Blazor renders. */

.boot-splash {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    background: linear-gradient(160deg, var(--brand-800), var(--brand-900) 70%);
}

.boot-logo { width: 16rem; max-width: 70vw; height: auto; }

.page-loading { padding: 3rem; text-align: center; color: var(--text-muted); }

/*
  The box has to be square. `r: 40%` on a circle resolves against the normalized
  diagonal — sqrt(w² + h²) / sqrt(2) — not the width. Leave the height off and the SVG
  falls back to its default 150px, making the radius larger than the half-width, so the
  ring is clipped at the left and right edges. Square keeps the diagonal equal to the
  side, so 40% is a true 40% of the box.

  overflow: visible is a safety net: SVG clips to its viewport by default, so a future
  size change can't quietly slice the stroke again.
*/
.loading-progress {
    position: relative;
    display: block;
    width: 6rem;
    height: 6rem;
    overflow: visible;
}

.loading-progress circle {
    fill: none;
    stroke: rgb(255 255 255 / 22%);
    stroke-width: .5rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--brand-mint);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * .8), 500%;
    transition: stroke-dasharray .05s ease-in-out;
}

.loading-progress-text { text-align: center; font-weight: 600; color: rgb(255 255 255 / 80%); }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: .8rem 1.25rem;
    background: #fff3cd;
    color: #664d03;
    box-shadow: 0 -1px 3px rgb(0 0 0 / 15%);
}

#blazor-error-ui .dismiss { cursor: pointer; float: right; }
