/* ==========================================================================
   Nova Dojo · access & error pages (D9)
   /auth/login, auth/denied.html and errors/403|404|500.html.
   Reads the global tokens from dojo.css when present (with fallbacks, so the
   standalone 500 page still looks right). Art macros: templates/errors/_art.html.
   ========================================================================== */

.auth-page, .err-page {
  --a-navy: var(--brand-navy, #1f3a5f);
  --a-navy-dark: var(--brand-navy-dark, #152a46);
  --a-teal: var(--brand-teal, #2a9d8f);
  --a-teal-dark: var(--brand-teal-dark, #1f7a6f);
  --a-teal-light: var(--brand-teal-light, #e3f4f1);
  --a-gold: var(--gold, #f5b82e);
  --a-gold-dark: var(--gold-dark, #c98f0a);
  --a-gold-light: var(--gold-light, #fef3c7);
  --a-ink: #1b1f2a;
  --a-muted: #5b6475;
  --a-line: rgba(27, 31, 42, .08);
  --a-field: #d5dae2;
  --a-paper: #ffffff;
  --a-shadow: 0 1px 2px rgba(27, 31, 42, .05), 0 18px 40px -18px rgba(27, 31, 42, .22);
  --a-display: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  --a-text: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--a-ink);
}

/* Inline stroke icons from the ico() macro. */
.auth-page .ico, .err-page .ico { width: 1.25rem; height: 1.25rem; flex-shrink: 0; }
.auth-page .art, .err-page .art { display: block; width: 100%; height: auto; }

/* The navbar "Log in" button is pointless on the login page itself. */
body:has(.auth-shell) header nav a[href="/auth/login"] { display: none; }

/* ------------------------------------------------------------ login grid */
.auth-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "hero" "card" "points";
  gap: 1.5rem;
}
.auth-panel-bg { display: none; }
.auth-hero { grid-area: hero; text-align: center; }
.auth-card { grid-area: card; }
.auth-points { grid-area: points; }

/* ----------------------------------------------------------------- hero */
.auth-hero__art { width: min(100%, 15rem); margin: 0 auto .5rem; }
.auth-hero__art img { display: block; width: 100%; height: auto; }

.auth-eyebrow {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .35rem .8rem; border-radius: 9999px;
  background: rgba(255, 255, 255, .8); border: 1px solid var(--a-line);
  color: var(--a-teal-dark); font: 700 .8125rem/1.2 var(--a-text);
}
.auth-eyebrow .ico { width: 1rem; height: 1rem; color: var(--a-gold-dark); }
.auth-title {
  margin-top: .75rem;
  font-family: var(--a-display); font-weight: 800; letter-spacing: -.015em;
  font-size: clamp(1.875rem, 1.1rem + 2.6vw, 3rem); line-height: 1.08;
  color: var(--a-navy); text-wrap: balance;
}
.auth-lead {
  margin: .75rem auto 0; max-width: 32rem;
  font: 400 1rem/1.55 var(--a-text); color: var(--a-muted); text-wrap: pretty;
}

/* ----------------------------------------------------------------- card */
.auth-card {
  position: relative; overflow: hidden;
  padding: 1.75rem 1.25rem 1.25rem;
  background: var(--a-paper); border: 1px solid var(--a-line); border-radius: 1.5rem;
  box-shadow: var(--a-shadow);
  display: flex; flex-direction: column; gap: 1.1rem;
}
/* The nine belts, white to black, as a ribbon on top of the card. */
.auth-card__belts {
  position: absolute; inset: 0 0 auto 0; height: 6px;
  background: linear-gradient(90deg,
    #e2e8f0 0 11.1%, #facc15 11.1% 22.2%, #f97316 22.2% 33.3%, #16a34a 33.3% 44.4%, #2563eb 44.4% 55.5%,
    #7c3aed 55.5% 66.6%, #8b5a2b 66.6% 77.7%, #dc2626 77.7% 88.8%, #111827 88.8% 100%);
}
.auth-card__head { display: flex; align-items: center; gap: .9rem; }
.auth-card__logo { width: 3.25rem; height: 3.25rem; border-radius: 1rem; flex-shrink: 0; box-shadow: 0 6px 14px -6px rgba(31, 58, 95, .5); }
.auth-card__title { font: 800 1.5rem/1.15 var(--a-display); color: var(--a-navy); }
.auth-card__sub { margin-top: .2rem; font: 400 .875rem/1.4 var(--a-text); color: var(--a-muted); }

.auth-alert {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .75rem .9rem; border-radius: 1rem;
  background: #fef2f2; border: 1px solid #fecaca; color: #7f1d1d;
  font: 600 .875rem/1.45 var(--a-text);
}
.auth-alert .ico { color: #dc2626; margin-top: .05rem; }
.auth-alert--info { background: var(--a-teal-light); border-color: #b9e3dc; color: #134e48; }
.auth-alert--info .ico { color: var(--a-teal-dark); }

/* Google button: white, logo on the left, soft 3D edge. */
.auth-google {
  display: flex; align-items: center; justify-content: center; gap: .75rem;
  width: 100%; min-height: 3.25rem; padding: .75rem 1.25rem;
  border: 1.5px solid var(--a-field); border-radius: 1rem; background: #fff;
  box-shadow: 0 3px 0 var(--a-field);
  font: 700 1rem/1.2 var(--a-text); color: var(--a-ink); text-decoration: none;
  transition: background-color .15s, transform .08s ease, box-shadow .08s ease;
}
.auth-google:hover { background: #f8fafc; }
.auth-google:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--a-field); }
.auth-google:focus-visible { outline: 3px solid color-mix(in srgb, var(--a-navy) 55%, white); outline-offset: 3px; }
.auth-google__logo { width: 1.375rem; height: 1.375rem; }
.auth-hint { margin-top: -.4rem; text-align: center; text-wrap: balance; font: 400 .8125rem/1.4 var(--a-text); color: var(--a-muted); }

.auth-or {
  display: flex; align-items: center; gap: .75rem;
  font: 700 .75rem/1 var(--a-text); letter-spacing: .06em; text-transform: uppercase; color: #94a3b8;
}
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--a-line); }

/* Development login: unmistakably not the real thing (dashed, caution stripes). */
.auth-dev {
  display: flex; flex-direction: column; gap: .6rem;
  padding: 1rem; border: 2px dashed #e9b649; border-radius: 1.1rem;
  background: repeating-linear-gradient(-45deg, #fffbf0 0 14px, #fff6df 14px 28px);
}
.auth-dev__head { display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; margin-bottom: .15rem; }
.auth-dev__tag {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .65rem; border-radius: 9999px; background: #422006; color: #fde68a;
  font: 800 .6875rem/1 var(--a-text); letter-spacing: .08em; text-transform: uppercase;
}
.auth-dev__tag .ico { width: .95rem; height: .95rem; }
.auth-dev__note { font: 400 .8125rem/1.45 var(--a-text); color: #713f12; }
.auth-dev__note strong { font-weight: 700; color: #422006; }
.auth-dev__note code { font-family: var(--font-mono, ui-monospace, monospace); font-size: .75rem; padding: .05rem .3rem; border-radius: .35rem; background: rgba(66, 32, 6, .08); }
.auth-label { font: 600 .875rem/1.2 var(--a-text); color: #334155; }
.auth-input {
  width: 100%; min-height: 3.25rem; padding: .75rem 1rem;
  border: 1.5px solid var(--a-field); border-radius: 1rem; background: #fff; color: var(--a-ink);
  font: 400 1rem/1.2 var(--a-text);
  transition: border-color .15s, box-shadow .15s;
}
.auth-input::placeholder { color: #94a3b8; }
.auth-input:focus { outline: none; border-color: var(--a-teal); box-shadow: 0 0 0 4px rgba(42, 157, 143, .2); }
.auth-dev .btn { margin-top: .35rem; }

.auth-signed { display: flex; flex-direction: column; gap: .9rem; }
.auth-signed__who { display: flex; align-items: center; gap: .75rem; font: 400 .9375rem/1.45 var(--a-text); color: #334155; }
.auth-signed__who strong { color: var(--a-ink); overflow-wrap: anywhere; }
.auth-link {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.75rem;
  font: 600 .875rem/1.2 var(--a-text); color: var(--a-muted); text-decoration: none; border-radius: .75rem;
}
.auth-link:hover { color: var(--a-navy); text-decoration: underline; }
.auth-link .ico { width: 1.05rem; height: 1.05rem; }
.btn .ico { width: 1.25rem; height: 1.25rem; }

.auth-foot {
  padding-top: .9rem; border-top: 1px solid var(--a-line);
  font: 400 .78rem/1.45 var(--a-text); color: #8a93a3; text-align: center; text-wrap: balance;
}
.auth-foot .ico { display: inline-block; width: 1rem; height: 1rem; margin-right: .3rem; vertical-align: -.2rem; color: var(--a-teal); }

/* --------------------------------------------------------------- points */
.auth-points { display: grid; gap: .75rem; }
.auth-point {
  display: flex; align-items: flex-start; gap: .9rem;
  padding: .95rem 1rem; border-radius: 1.1rem;
  background: rgba(255, 255, 255, .78); border: 1px solid var(--a-line);
}
.auth-point__icon {
  display: grid; place-items: center; flex-shrink: 0;
  width: 2.75rem; height: 2.75rem; border-radius: .9rem;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12);
}
.auth-point__icon .ico { width: 1.4rem; height: 1.4rem; }
.auth-point__icon.is-teal { background: var(--a-teal); color: #fff; }
.auth-point__icon.is-gold { background: var(--a-gold); color: #422006; }
.auth-point__icon.is-navy { background: var(--a-navy); color: #fde68a; }
.auth-point__title { font: 800 1rem/1.25 var(--a-display); color: var(--a-navy); }
.auth-point__text { margin-top: .15rem; font: 400 .875rem/1.45 var(--a-text); color: var(--a-muted); }

@media (min-width: 640px) {
  .auth-shell { gap: 2rem; }
  .auth-hero__art { width: min(100%, 20rem); }
  .auth-card { padding: 2.25rem 2rem 1.5rem; max-width: 30rem; width: 100%; margin-inline: auto; }
  .auth-points { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .auth-point { flex-direction: column; gap: .7rem; }
}

@media (min-width: 1024px) {
  .auth-shell {
    grid-template-columns: minmax(0, 1.14fr) minmax(0, .86fr);
    grid-template-rows: auto auto;
    grid-template-areas: "hero card" "points card";
    column-gap: 3rem; row-gap: 0;
    min-height: min(calc(100vh - 10rem), 54rem);
    align-content: center;
  }
  .auth-panel-bg {
    display: block; position: relative; overflow: hidden;
    grid-column: 1; grid-row: 1 / span 2;
    border-radius: 1.75rem; border: 1px solid var(--a-line);
    background:
      radial-gradient(70% 55% at 88% 8%, rgba(245, 184, 46, .30), transparent 70%),
      radial-gradient(65% 55% at 0% 100%, rgba(42, 157, 143, .24), transparent 70%),
      linear-gradient(160deg, #e8f5f2 0%, #f6f4ef 55%, #fcf1d6 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8);
  }
  /* Faint tatami grid. */
  .auth-panel-bg::after {
    content: ""; position: absolute; inset: 0; opacity: .5;
    background-image:
      linear-gradient(90deg, rgba(31, 58, 95, .05) 1px, transparent 1px),
      linear-gradient(0deg, rgba(31, 58, 95, .05) 1px, transparent 1px);
    background-size: 96px 48px;
    mask-image: linear-gradient(180deg, transparent, #000 35%, #000 70%, transparent);
  }
  .auth-hero, .auth-points { position: relative; z-index: 1; padding-inline: 2.75rem; }
  .auth-hero { padding-top: 2.25rem; text-align: left; }
  .auth-hero__art { width: min(100%, 26rem); margin: 0 auto 1rem; }
  .auth-title { font-size: clamp(2.25rem, 1rem + 2vw, 2.75rem); }
  .auth-lead { margin-inline: 0; }
  .auth-points { padding-top: 1.75rem; padding-bottom: 2.5rem; }
  .auth-point { background: rgba(255, 255, 255, .72); backdrop-filter: blur(4px); }
  .auth-card { align-self: center; max-width: none; margin: 0; }
}

/* ========================================================= error pages */
.err-page { padding-block: .5rem 1.5rem; }
.err-stage {
  position: relative; overflow: hidden;
  display: grid; gap: 1.25rem; align-items: center;
  padding: 1.75rem 1.25rem 2rem;
  border-radius: 1.75rem; border: 1px solid var(--a-line);
  background:
    radial-gradient(70% 60% at 100% 0%, rgba(245, 184, 46, .24), transparent 70%),
    radial-gradient(60% 60% at 0% 100%, rgba(42, 157, 143, .20), transparent 70%),
    linear-gradient(160deg, #e8f5f2 0%, #f6f4ef 55%, #fcf1d6 100%);
  box-shadow: var(--a-shadow);
  text-align: center;
}
.err-stage__art { width: min(100%, 15rem); margin-inline: auto; }
.err-code {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .35rem .8rem; border-radius: 9999px;
  background: rgba(255, 255, 255, .85); border: 1px solid var(--a-line);
  color: var(--a-teal-dark); font: 800 .75rem/1.2 var(--a-text); letter-spacing: .08em; text-transform: uppercase;
}
.err-code .ico { width: 1rem; height: 1rem; }
.err-title {
  margin-top: .75rem;
  font-family: var(--a-display); font-weight: 800; letter-spacing: -.01em;
  font-size: clamp(1.75rem, 1.2rem + 1.9vw, 2.625rem); line-height: 1.1;
  color: var(--a-navy); text-wrap: balance;
}
.err-text {
  margin: .85rem auto 0; max-width: 34rem;
  font: 400 1.0625rem/1.6 var(--a-text); color: var(--a-muted); text-wrap: pretty;
}
.err-text strong { color: var(--a-ink); font-weight: 600; word-break: break-word; }
.err-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .75rem; margin-top: 1.75rem; }
.err-actions .btn { flex: 1 1 100%; }
.err-more { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem 1.25rem; margin-top: .75rem; }
.err-link {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 2.75rem; padding-inline: .25rem;
  background: none; border: 0; cursor: pointer;
  font: 600 .9rem/1.2 var(--a-text); color: var(--a-muted); text-decoration: none; border-radius: .6rem;
}
.err-link:hover { color: var(--a-navy); text-decoration: underline; }
.err-link .ico { width: 1.05rem; height: 1.05rem; }

@media (min-width: 640px) {
  .err-actions .btn { flex: 0 0 auto; min-width: 12rem; }
  .err-stage__art { width: min(100%, 19rem); }
}
@media (min-width: 900px) {
  .err-page { padding-block: 1.5rem 2.5rem; }
  .err-stage {
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    gap: 2.5rem; padding: 3rem 3.5rem; text-align: left;
    min-height: 26rem;
  }
  .err-stage__art { width: 100%; max-width: 24rem; }
  .err-text { margin-inline: 0; }
  .err-actions, .err-more { justify-content: flex-start; }
}

/* ------------------------------------------------------------- motion */
.art-float, .art-twinkle, .art-wobble, .art-swing { transform-box: fill-box; transform-origin: center; }
.art-float { animation: art-float 4.2s ease-in-out infinite; }
.art-float--late { animation-delay: -1.6s; }
.art-float--slow { animation-duration: 5.6s; animation-delay: -3s; }
.art-twinkle { animation: art-twinkle 2.8s ease-in-out infinite; }
.art g:nth-of-type(2n) > .art-twinkle { animation-delay: -1.3s; }
.art-wobble { animation: art-wobble 3.2s ease-in-out infinite; }
.art-swing { transform-origin: 50% 0; animation: art-swing 4s ease-in-out infinite; }
@keyframes art-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes art-twinkle { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.7); opacity: .55; } }
@keyframes art-wobble { 0%, 100% { transform: rotate(-35deg); } 30% { transform: rotate(50deg); } 60% { transform: rotate(-10deg); } 80% { transform: rotate(120deg); } }
@keyframes art-swing { 0%, 100% { transform: rotate(-2.5deg); } 50% { transform: rotate(2.5deg); } }
@media (prefers-reduced-motion: reduce) {
  .art-float, .art-twinkle, .art-wobble, .art-swing { animation: none; }
}
