/* ==============================================================================
   HTMX GO TEMPLATE - Main CSS Entry Point
   ============================================================================== */

/* The stylesheets under 01-foundation … 04-interactive are linked one by
   one from templates/layout.html, before this file and in cascade order,
   each with its own content hash: an @import here could not carry a ?v=,
   so an edited component file stayed cached under the one-day policy
   while main.css itself moved on. This file keeps only the base styles,
   last in the cascade as they always were. */

/* ==============================================================================
   BASE STYLES
   ============================================================================== */

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

html {
  scroll-behavior: smooth;
}

/* One guard for the whole site: whoever asked the OS for less motion gets
   no transitions, no animations and no smooth scroll, whatever a component
   below declares. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-text);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--page-bg);
  /* dvh follows the mobile browser chrome; the vh line is the fallback */
  min-height: 100vh;
  min-height: 100dvh;
}

/* Keyboard focus is visible everywhere; mouse clicks do not show the ring */
:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Skip link: first tab stop, visible only while focused */
.skip-link {
  position: absolute;
  top: var(--spacing-sm, 0.5rem);
  left: var(--spacing-sm, 0.5rem);
  padding: var(--spacing-sm, 0.5rem) var(--spacing-md, 1rem);
  background: var(--paper-bg);
  color: var(--text-primary);
  border-radius: var(--radius-md, 8px);
  box-shadow: var(--shadow-md);
  z-index: var(--z-toast, 1100);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(0);
}

h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  font-family: var(--font-title);
  line-height: 1.2;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

/* <picture> renders inline by default, which leaves its <img> resolving
   percentage widths against the wrong box in some browsers; every block
   that wraps an image in a <picture> already sizes the <img> itself, so
   the wrapper only needs to get out of the way. */
picture {
  display: block;
}

/* Utility classes */
/* The hidden attribute must win over any display a class sets (.btn is
   inline-flex): the copy buttons of the portal and the denied page are
   born hidden and only JavaScript reveals them. Without this rule a
   browser without JavaScript showed buttons that could do nothing. */
[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  /* Inside the viewport on a phone: 16px gutter on each side */
  max-width: calc(100% - 2rem);
  padding: var(--spacing-md, 1rem) var(--spacing-lg, 1.5rem);
  background: var(--paper-bg);
  border-radius: var(--radius-md, 8px);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-toast, 1100);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm, 0.5rem);
  animation: slideIn 0.3s ease;
}

.toast-success {
  border-left: 4px solid var(--accent-green);
}

.toast-error {
  border-left: 4px solid var(--color-danger);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Zoom wrapper - content that can be zoomed */
#zoom-wrapper {
  transform-origin: top center;
  transition: transform 0.2s ease;
}

/* ==============================================================================
   ADMIN PREVIEW STRIP
   ============================================================================== */

/* The strip the admin's draft preview paints above the content (see
   PageHandler.RenderDraft). It lives here and not in admin.css because the
   preview is the public layout, which never links admin.css; no public
   page ever renders the element, so the rule costs visitors nothing. */
.preview-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  /* A dark amber no skin uses for anything else, so the strip never
     blends into the page under it; white on it is above 7:1. */
  background: #8a5a00;
  color: #ffffff;
  font-weight: 600;
  text-align: center;
}

/* ==============================================================================
   TOUCH TARGETS
   ============================================================================== */

/* On a phone or a tablet every control is at least 44px tall (WCAG 2.5.8,
   the sweep of responsive-testing): buttons, fields, the language switcher,
   the header's links, the admin's menu and tabs. Desktop keeps the compact
   sizes each component sets; the slideshow dot keeps its 10px mark and
   grows only its hit area. A link inside a paragraph is text, not a
   control, and stays as it is. main.css and not each component's file
   because the rule is one decision about the whole site, not per part. */
@media (max-width: 768px) {
  .btn,
  .prefs__btn,
  .lang-switch__link,
  .site-header__logo,
  .site-nav__list a,
  .skip-link,
  .admin-bar-site,
  .admin-nav a,
  .page-tabs a,
  .inbox-filters a,
  .inbox-pager a,
  .form-group input:not([type="checkbox"]):not([type="radio"]),
  .form-group select,
  .form-group textarea,
  .table-row-form input:not([type="checkbox"]),
  .table-row-form select,
  .media-toolbar input,
  .media-toolbar select,
  .media-upload input,
  .texts-filter input[type="search"] {
    min-height: 44px;
  }

  .lang-switch__link,
  .site-header__logo,
  .site-nav__list a,
  .admin-bar-site,
  .page-tabs a,
  .inbox-filters a,
  .inbox-pager a {
    display: inline-flex;
    align-items: center;
  }

  .slideshow-dot {
    width: 44px;
    height: 44px;
  }

  input[type="checkbox"],
  input[type="radio"] {
    width: 24px;
    height: 24px;
  }
}
