/* ==========================================================================
   richter2026 — layout.css
   Page skeleton: container, content grid, column layout.
   Replaces the legacy fixed 980px #container / #mainFrame-left/right
   table-image layout with a fluid, responsive grid.
   Milestone: 0.1 Foundation
   ========================================================================== */

/* IMPORTANT — structural note (verified against the real header.tpl/
   footer.tpl div nesting, not assumed):

   #container wraps the ENTIRE page — header, body, and footer are all
   inside it, in this exact order:

     #container
       #header (now <header>)
       #mainFrame-left > #mainFrame-right > [column-left,
         column-right, #content]
       #footer-left > #footer-right > [iCustomFooter widgets],
         then #footer, #powered (siblings of #footer-right, still
         inside #footer-left)

   Because the header/footer need a full-bleed dark background while
   the body content stays width-constrained, #container itself is NOT
   constrained — only an inner max-width wrapper is. The header/footer
   templates each render their own ".richter-header"/full-bleed
   background, with a max-width inner element for their content. */

#container {
  width: 100%;
  background: var(--color-bg);
  text-align: left;
}

#mainFrame-left,
#mainFrame-right {
  background: none; /* legacy repeating border images removed */
}

/* flex-wrap lets full-width messages (.richter-main > .success etc., below)
   take a row of their own. */
.richter-main {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-8);
  max-width: var(--container-width);
  margin: 0 auto;
  padding: var(--space-8) var(--container-padding);
}

#column-left {
  flex: 0 0 240px;
  width: 240px;
}

#column-right {
  flex: 0 0 240px;
  width: 240px;
  order: 3;
}

#content {
  flex: 1 1 0%;
  min-width: 0;
  min-height: 400px;
  background: var(--color-bg);
}

/* ---- Notifications --------------------------------------------------------
   #notification is a fixed toast container, filled by catalog-actions.js
   (richterNotify). A message never pushes the page down or scrolls it. */

#notification {
  position: fixed;
  top: calc(var(--header-height) + var(--space-3));
  right: var(--space-5);
  z-index: var(--z-modal);
  width: min(420px, calc(100vw - 2 * var(--space-5)));
  pointer-events: none;
}

#notification:empty {
  display: none;
}

#notification > * {
  position: relative;
  margin: 0;
  padding: var(--space-4) calc(var(--space-5) + 28px) var(--space-4) var(--space-5);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-left-width: 4px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: richter-toast-in 0.25s ease-out;
}

#notification > .success {
  border-left-color: var(--color-stock-in);
}

#notification > .warning {
  border-left-color: var(--color-stock-out);
}

#notification a {
  font: inherit;
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
  text-decoration: underline;
}

#notification > .is-leaving {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#notification .close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  float: none;
  width: 18px;
  height: 18px;
  opacity: 0.6;
  cursor: pointer;
}

#notification .close:hover {
  opacity: 1;
}

@keyframes richter-toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

.richter-main > .success,
.richter-main > .warning,
.richter-main > .attention,
.richter-main > .information {
  order: -1;
  flex: 1 1 100%;
  width: 100%;
  margin-bottom: var(--space-5);
}

.richter-section {
  padding: var(--space-16) 0;
}

.richter-section--subtle {
  background: var(--color-bg-subtle);
}

.richter-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.richter-section-heading h2 {
  margin-bottom: 0;
}

.richter-section-heading .richter-section-link {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
}

/* Simple responsive grid utility used across product/category listings */
.richter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-6);
}

.richter-grid--2 { grid-template-columns: repeat(2, 1fr); }
.richter-grid--3 { grid-template-columns: repeat(3, 1fr); }
.richter-grid--5 { grid-template-columns: repeat(5, 1fr); }

.clearfix::after {
  content: "";
  display: table;
  clear: both;
}

/* ---- Responsive breakpoints ---------------------------------------- */

@media (max-width: 991px) {
  #notification {
    top: calc(var(--header-height-mobile) + var(--space-2));
    left: var(--space-3);
    right: var(--space-3);
    width: auto;
  }

  .richter-main {
    flex-wrap: wrap;
  }

  #column-left,
  #column-right {
    flex: 1 1 100%;
    width: 100%;
    order: 2;
  }

  #content {
    order: 1;
    flex: 1 1 100%;
  }

  .richter-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .richter-grid--5 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 599px) {
  :root {
    --container-padding: var(--space-4);
  }

  .richter-grid,
  .richter-grid--3,
  .richter-grid--5 {
    grid-template-columns: repeat(2, 1fr);
  }

  .richter-section {
    padding: var(--space-6) 0;
  }
}

/* ---- v0.9 Polish: page-level refinements ------------------------------- */

/* Smooth scroll for anchor navigation (tab links, #review, etc.) */
html {
  scroll-behavior: smooth;
}

/* Focus ring that matches the brand — browser default is often
   ugly/invisible, this makes keyboard navigation clearly visible */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  #notification > *,
  #notification > .is-leaving {
    animation: none;
    transition: none;
  }
}
