/*!
 * Kadrio — Global Layout & Shell (main.css)
 * ----------------------------------------------------------------------------
 * Layout, header/navigation and shared shell styles.
 * Contains NO raw color values — everything references tokens from theme.css.
 *
 * TABLE OF CONTENTS
 * ----------------------------------------------------------------------------
 *  1. Reset & base
 *  2. Background glow
 *  3. Accessibility (focus, reduced motion)
 *  3a. No-JavaScript banner (<noscript>)
 *  4. Header & top navigation
 *  5. Header action buttons
 *  6. Main layout & cards
 *  7. Responsive
 *  8. RTL adjustments
 *  9. Print
 * ----------------------------------------------------------------------------
 */

/* ========================================================================== */
/* 1. Reset & base                                                            */
/* ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* The hidden attribute must always win, even over display classes
   (flex/grid utilities would otherwise override the UA rule). */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-base);
  color: var(--text);
  background-color: var(--bg-app);
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* ========================================================================== */
/* 2. Background glow — warm radial accents in the page corners               */
/* ========================================================================== */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(600px 420px at 88% -5%, var(--bg-glow), transparent 70%),
    radial-gradient(520px 380px at -4% 104%, var(--bg-glow), transparent 70%);
}

/* ========================================================================== */
/* 3. Accessibility                                                           */
/* ========================================================================== */

/* Accessible focus indicator: a two-ring halo (inner surface + outer text)
   that stays visible on ANY background — light page, dark pill, accent button
   — meeting WCAG 1.4.11. The transparent outline is the forced-colors-mode
   fallback (it becomes a system color where box-shadow is ignored). The rings
   follow the element's own border-radius. */
:focus-visible {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ========================================================================== */
/* 3a. No-JavaScript banner (<noscript>)                                      */
/*     Shown only when the visitor has JavaScript disabled (progressive       */
/*     enhancement — Envato soft-reject guard). Full-width, centred, in the    */
/*     warning palette so it reads as an actionable notice, not page chrome.   */
/* ========================================================================== */

.noscript-banner {
  padding: var(--sp-3) var(--sp-4);
  background-color: var(--warning-soft);
  color: var(--warning-text);
  border-bottom: 1px solid var(--warning);
  text-align: center;
  font-size: var(--fs-small);
  font-weight: var(--fw-semibold);
}

/* ========================================================================== */
/* 4. Header & top navigation                                                 */
/* ========================================================================== */

/* Skip-to-content link: off-screen until focused (keyboard a11y). */
.skip-link {
  position: absolute;
  inset-inline-start: var(--sp-4);
  top: -120px;
  z-index: var(--z-toast);
  padding: var(--sp-2) var(--sp-4);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-small);
  font-weight: var(--fw-semibold);
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: var(--sp-3);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background-color: var(--bg-app);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-6);
}

/* Logo pill ---------------------------------------------------------------- */

.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-card);
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-pill);
  background-color: var(--accent);
  color: var(--text-on-accent);
  font-size: var(--fs-small);
  font-weight: var(--fw-bold);
}

.logo-name {
  font-size: var(--fs-h3);
  font-weight: var(--fw-semibold);
}

/* Navigation pills ---------------------------------------------------------- */

.app-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin: 0 auto;
  padding: var(--sp-1);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-card);
}

.nav-pill {
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-pill);
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  white-space: nowrap;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.nav-pill:hover {
  background-color: var(--surface-alt);
  color: var(--text);
}

.nav-pill.is-active {
  background-color: var(--dark);
  color: var(--text-on-dark);
}

/* ========================================================================== */
/* 5. Header action buttons                                                   */
/* ========================================================================== */

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-inline-start: auto;
}

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text);
  transition: background-color var(--transition-fast);
}

.icon-btn:hover {
  background-color: var(--surface-alt);
}

/* The active header icon (e.g. Settings on the settings page). */
.icon-btn[aria-current='page'] {
  background-color: var(--accent-soft);
  color: var(--text);
}

.notif-dot {
  position: absolute;
  top: 9px;
  inset-inline-end: 10px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background-color: var(--accent);
  border: 2px solid var(--surface);
}

.avatar-btn {
  border-radius: var(--radius-pill);
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  background-color: var(--accent-soft);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: var(--fs-small);
  font-weight: var(--fw-semibold);
}

/* Hamburger is hidden on desktop. */
.nav-toggle {
  display: none;
}

/* ========================================================================== */
/* 6. Main layout & cards                                                     */
/* ========================================================================== */

.app-main {
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-6) var(--sp-12);
}

.page-title {
  font-size: var(--fs-h1);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
}

.page-subtitle {
  margin-top: var(--sp-2);
  color: var(--text-secondary);
}

.card {
  margin-top: var(--sp-5);
  padding: var(--sp-6);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.card-title {
  font-size: var(--fs-h2);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
}

.card-text {
  margin-top: var(--sp-3);
  color: var(--text-secondary);
  max-width: 60ch;
}

/* ========================================================================== */
/* 7. Responsive                                                              */
/* ========================================================================== */

@media (max-width: 1200px) {
  .app-nav {
    gap: var(--sp-1);
  }

  .nav-pill {
    padding: var(--sp-2) var(--sp-2);
  }
}

/* The 9-item nav collapses to a hamburger panel below 1100px — with nine pills
   the bar would otherwise crowd the logo and header actions on mid-width
   screens. Above this width the full pill bar fits (tightened by the 1200px
   rule above). */
@media (max-width: 1100px) {
  .header-inner {
    position: relative;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .app-nav {
    display: none;
    position: absolute;
    top: calc(100% + var(--sp-1));
    inset-inline: var(--sp-4);
    flex-direction: column;
    align-items: stretch;
    padding: var(--sp-2);
    border-radius: var(--radius-inner);
    box-shadow: var(--shadow-pop);
    z-index: var(--z-dropdown);
  }

  .app-nav.is-open {
    display: flex;
  }

  .app-nav .nav-pill {
    padding: var(--sp-3) var(--sp-4);
  }
}

@media (max-width: 768px) {
  .header-inner {
    padding: var(--sp-3) var(--sp-4);
  }

  .app-main {
    padding: var(--sp-4) var(--sp-4) var(--sp-10);
  }

  .page-title {
    font-size: var(--fs-h2);
  }
}

/* ========================================================================== */
/* 8. RTL adjustments                                                         */
/*    Layout mirrors automatically via logical properties; only directional   */
/*    prev/next chevrons need an explicit horizontal flip.                     */
/* ========================================================================== */

[dir='rtl'] .date-nav svg,
[dir='rtl'] .pagination svg {
  transform: scaleX(-1);
}

/* ========================================================================== */
/* 9. Print                                                                   */
/* ========================================================================== */

@media print {
  .app-header,
  .page-actions,
  .toast-region,
  .no-print {
    display: none !important;
  }

  body::before {
    display: none;
  }

  .app-main {
    max-width: none;
    padding: 0;
  }

  .card {
    border: 0;
    box-shadow: none;
    padding: 0;
  }
}
