/*
The frame every page shares: the header, the message strip, the footer, the pager, the error page, the signed-in
column, and the form fields allauth and form_tags render. Loaded after site.css on every page (web/base.html).
*/

@layer site {
  /* ---- header (web/components/top_nav.html) ---- */

  .site-nav {
    border-bottom: 1px solid var(--line);
    background: var(--color-base-100);
  }
  .site-nav-bar {
    min-height: 3.75rem;
    gap: 0.5rem;
    padding-inline: 1rem;
    @media (width >= 40rem) { gap: 0.875rem; padding-inline: 1.5rem; }
  }
  .site-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-inline-end: 0.5rem;
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    @media (width >= 40rem) { margin-inline-end: 1rem; }
  }
  /* the mark: the brand's initial on its gradient */
  .site-logo {
    display: grid;
    width: 1.875rem;
    height: 1.875rem;
    place-items: center;
    border-radius: 0.5rem;
    background-image: linear-gradient(135deg, var(--color-accent), var(--color-primary));
    box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--color-primary-content) 18%, transparent);
    color: var(--color-primary-content);
    font-size: 0.9375rem;
    font-weight: 700;
  }
  /* on a phone the script switch needs the room, so the name gives way to the mark (the link keeps its label) */
  .site-nav-bar:has(.site-script) .site-brand-name {
    @media (width < 40rem) { display: none; }
  }
  .site-sections {
    display: flex;
    gap: 0.125rem;
    margin-inline-end: auto;
    @media (width >= 40rem) { gap: 0.25rem; }
  }
  /* a section: a ghost button with its icon, the current one in the brand's tint; daisyUI's own hover would be the
     page's grey */
  .site-section {
    gap: 0.5rem;
    font-size: 0.90625rem;
    font-weight: 500;
    color: var(--muted);
    & svg { flex: none; width: 1rem; height: 1rem; }
    &:hover { background-color: var(--color-base-200); color: var(--color-base-content); }
    &[aria-current='page'] {
      background-color: var(--tint);
      color: var(--color-primary);
      font-weight: 600;
    }
  }
  /* the assistant's sparkle keeps the brand colour */
  .site-ai { color: var(--color-accent); }
  /* below sm a section is its icon; the name stays for screen readers */
  @media (width < 40rem) {
    .site-sections .site-section {
      width: var(--size);
      padding-inline: 0;
      & > span {
        position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
      }
    }
  }
  .site-script {
    margin-inline-end: 0.25rem;
    & .tab { font-weight: 600; }
    @media (width >= 40rem) { margin-inline-end: 0.75rem; }
  }
  /* the account's toggle: the avatar and a chevron, shaded while its popover is open */
  .site-account-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    border-radius: 9999px;
    cursor: pointer;
    &:hover, &:has(+ :popover-open) { background: var(--color-base-200); }
  }
  .site-avatar {
    display: grid;
    width: 1.875rem;
    height: 1.875rem;
    place-items: center;
    border-radius: 50%;
    background: var(--color-accent);
    color: var(--color-accent-content);
    font-size: 0.75rem;
    font-weight: 700;
  }
  .site-chevron {
    display: none;
    width: 0.875rem;
    height: 0.875rem;
    margin-inline-end: 0.25rem;
    color: var(--muted);
    @media (width >= 40rem) { display: block; }
    .site-account-toggle:has(+ :popover-open) & { rotate: 180deg; }
  }
  /* the account's links: .site-menu's box and rows (components.css), each row as wide as the box; the links are
     classless, so the base link look would colour them */
  .site-account-menu {
    width: 16rem;
    margin-block-start: 0.5rem;
    & :is(a, button) { width: 100%; color: inherit; }
    & svg {
      fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
      color: var(--muted);
    }
  }
  .site-account-head {
    margin-bottom: 0.25rem;
    padding: 0.5rem 0.75rem 0.625rem;
    border-bottom: 1px solid var(--line);
    font-size: 0.8125rem;
    & p:first-child { font-weight: 600; }
  }
  .site-logout {
    margin-top: 0.25rem;
    padding-top: 0.25rem;
    border-top: 1px solid var(--line);
  }
  .site-guest {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-inline-start: auto;
  }

  /* ---- messages and the htmx error strip (web/base.html) ---- */

  .site-error {
    display: flex;
    justify-content: space-between;
    border-width: 0 0 1px;
    border-radius: 0;
    padding: 0.625rem 1.5rem;
    font-size: 0.8125rem;
  }
  .site-messages {
    display: grid;
    gap: 0.5rem;
    padding-top: 1.25rem;
  }
  .site-message {
    display: flex;
    align-items: flex-start;
    font-size: 0.84375rem;
    /* a predmet's name without spaces ("je obrisan") breaks inside the banner */
    & > div { flex: 1; overflow-wrap: anywhere; }
  }
  /* a banner's ×, a 24px target */
  .dismiss {
    display: grid;
    flex: none;
    place-items: center;
    min-width: 1.5rem;
    min-height: 1.5rem;
    border-radius: 0.25rem;
    font-size: 1.125rem;
    line-height: 1;
    opacity: 0.6;
    cursor: pointer;
    &:is(:hover, :focus-visible) { opacity: 1; }
  }

  /* ---- footer ---- */

  .site-footer {
    margin-top: auto;
    border-top: 1px solid var(--line);
    background: var(--color-base-100);
    & .page {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 0.75rem;
      padding-block: 1.25rem;
      font-size: 0.8125rem;
      color: var(--subtle);
    }
  }
  .site-footer-link:hover { color: var(--color-primary); }

  /* ---- pager (web/components/paginator_htmx.html) ---- */

  .pager {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding-top: 1rem;
  }
  .pager-pages {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    font-variant-numeric: tabular-nums;
  }
  .pager-num { min-width: 2.25rem; }
  /* white on the grey results pane, where daisyUI's plain button would be the page's own grey */
  .pager-btn {
    --btn-color: var(--color-base-100);
    border-color: var(--line);
  }
  .pager-gap {
    min-width: 1.5rem;
    text-align: center;
    color: var(--muted);
  }
  .pager-range {
    font-size: 0.8125rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
  }

  /* ---- the error pages and the signed-in column ---- */

  .error-page {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    max-width: 36rem;
    margin-inline: auto;
    padding: 4rem 1.5rem;
  }
  .error-card {
    padding: 2rem;
    & h1 { margin-bottom: 0.5rem; }
    & p { font-size: 0.9375rem; }
    & .btn { align-self: flex-start; margin-top: 1.5rem; }
  }
  .app-main { padding-block: 2rem; }

  /* ---- forms: allauth's elements and form_tags' fields ---- */

  /* the signed-in account pages: one card in the column (allauth/layouts/manage.html) */
  .manage-card {
    max-width: 48rem;
    margin-inline: auto;
    padding: 1.5rem;
    & h1 { margin-bottom: 1rem; }
    @media (width >= 40rem) { padding: 2rem; }
  }
  .allauth-heading { margin-bottom: 0.5rem; }
  .form-field { margin-bottom: 0.5rem; }
  .form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    cursor: pointer;
  }
}
