@layer theme, base, components, utilities;

/* --- Base */
@layer base {
  :focus-visible {
    outline: 3px solid var(--color-brand, #5e474a);
    outline-offset: 3px;
  }

  @media (prefers-reduced-motion: reduce) {
    * {
      scroll-behavior: auto !important;
      transition: none !important;
      animation: none !important;
    }
  }
}

@layer components {
  /* --- Header and footer */
  .skip-link {
    position: absolute;
    left: -9999px;
  }
  .skip-link:focus {
    left: 1rem;
    top: 1rem;
    z-index: 50;
    border-radius: 0.375rem;
    background: var(--color-brand, #880015);
    color: var(--color-on-brand, #fff);
    padding: 0.5rem 1rem;
  }

  .nav-link {
    text-decoration-thickness: 2px;
    text-underline-offset: 8px;
  }
  .nav-link:hover,
  .nav-link[aria-current="page"] {
    color: var(--color-brand, #880015);
    text-decoration-line: underline;
  }

  .footer-link {
    text-decoration-line: underline;
    text-underline-offset: 4px;
  }
  .footer-link:hover {
    color: #fff;
  }

  /* --- Dark mode toggle (moon in light mode, sun in dark mode) */
  .theme-toggle {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid color-mix(in srgb, var(--color-ink, #1a1a1a) 20%, transparent);
    border-radius: 9999px;
    cursor: pointer;
  }
  .theme-toggle:hover {
    border-color: var(--color-brand, #880015);
    color: var(--color-brand, #880015);
  }
  .theme-toggle svg {
    width: 1.25rem;
    height: 1.25rem;
  }
  .theme-toggle .icon-sun,
  [data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
  }
  [data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
  }

  /* --- Dark mode fixes for things that can't just change colour */

  /* the footer stays dark in both themes */
  [data-theme="dark"] site-footer footer {
    --color-ink: #0a0a0a;
    --color-paper: #e8e8e8;
  }

  /* the logo is black text on a light box: flip it to light text and blend the box into the page */
  [data-theme="dark"] .logo {
    filter: invert(1) hue-rotate(180deg);
    mix-blend-mode: lighten;
  }

  /* --- Page structure  */
  .page-title {
    font-family: var(--font-serif, Georgia, serif);
    font-size: 2.25rem;
    line-height: 1.15;
  }
  @media (min-width: 40rem) {
    .page-title {
      font-size: 3rem;
    }
  }

  .section-title {
    font-family: var(--font-serif, Georgia, serif);
    font-size: 1.875rem;
    line-height: 1.2;
  }

  .kicker {
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-brand, #880015);
  }

  .rule {
    border-color: color-mix(in srgb, var(--color-ink, #1a1a1a) 15%, transparent);
  }

  /* Picture with a shadow, and the small grey text used for captions and hints */
  .figure-img {
    width: 100%;
    height: auto;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  }
  .caption,
  .hint {
    font-size: 0.875rem;
    color: color-mix(in srgb, var(--color-ink, #1a1a1a) 70%, transparent);
  }
  .caption {
    margin-top: 0.5rem;
  }
  .hint {
    margin-top: 0.25rem;
  }

  /* --- Buttons and links  */
  .btn,
  .btn-outline {
    display: inline-block;
    border-radius: 0.375rem;
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    border: 2px solid var(--color-brand, #880015);
  }
  .btn {
    background: var(--color-brand, #880015);
    color: var(--color-on-brand, #fff);
  }
  .btn:hover {
    background: var(--color-brand-dark, #5e000f);
    border-color: var(--color-brand-dark, #5e000f);
  }
  .btn-primary {
    background: var(--color-brand-dark,#880015);
    border-color: var(--color-brand-dark, #5e000f);
  }
  .btn-primary:hover {
    background: var(--color-brand, #5e000f);
    border-color: var(--color-brand, #880015);
  }
  .btn-secondary {
    background: var(--color-brand-light, #f9e6e9);
    border-color: var(--color-brand-light, #f9e6e9);
    color: var(--color-brand, #880015);
  }
  .btn-secondary:hover {
    background: var(--color-brand, #880015);
    color: var(--color-on-brand, #fff);
  }
  .btn-outline {
    color: var(--color-brand, #880015);
  }
  .btn-outline:hover {
    background: var(--color-brand, #880015);
    color: var(--color-on-brand, #fff);
  }

  .link {
    color: var(--color-brand, #880015);
    text-decoration-line: underline;
    text-underline-offset: 4px;
  }
  .link:hover {
    color: var(--color-brand-dark, #5e000f);
  }

  /* --- Cards  */
  .card {
    border-radius: 0.5rem;
    background: var(--color-surface, #fff);
    padding: 1.5rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  }

  .product {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border-radius: 0.5rem;
    background: var(--color-surface, #fff);
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  }
  .product > img {
    width: 100%;
    height: auto;
  }
  .product-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 1.25rem;
  }
  .product-body h3 {
    margin-top: 0.25rem;
    font-family: var(--font-serif, Georgia, serif);
    font-size: 1.5rem;
  }
  .product-body ul {
    margin-top: 0.75rem;
    padding-left: 1.25rem;
    list-style: disc;
    font-size: 0.875rem;
  }
  .product:hover {
    box-shadow:
      0 0 0 1px var(--color-brand, #880015),
      0 1px 3px 0 rgb(0 0 0 / 0.1),
      0 1px 2px -1px rgb(0 0 0 / 0.1);
  }
  .product-nohover:hover {
    border-width: 0;
    border-color: transparent;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  }
  .price {
    margin-top: auto;
    padding-top: 1rem;
    font-family: var(--font-serif, Georgia, serif);
    font-size: 1.5rem;
  }
  .tag {
    border-radius: 0.25rem;
    background: color-mix(in srgb, var(--color-brand, #880015) 15%, transparent);
    padding: 0 0.5rem;
    vertical-align: middle;
    font-family: ui-sans-serif, system-ui, sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-brand, #880015);
  }

  /* --- Events timetable */
  .timetable th,
  .timetable td {
    padding: 0.75rem 1rem;
  }
  .timetable th {
    font-weight: 600;
  }
  .timetable tbody td {
    white-space: nowrap;
  }
  .timetable tbody tr + tr {
    border-top: 1px solid color-mix(in srgb, var(--color-ink, #1a1a1a) 10%, transparent);
  }

  /* --- Booking form */
  .label {
    display: block;
    font-weight: 600;
  }

  .field {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    border: 1px solid color-mix(in srgb, var(--color-ink, #1a1a1a) 30%, transparent);
    border-radius: 0.375rem;
    background: var(--color-surface, #fff);
    padding: 0.5rem 0.75rem;
  }
  .field:focus {
    border-color: var(--color-brand, #880015);
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-brand, #880015) 30%, transparent);
  }
  .field:user-invalid {
    border-color: var(--color-danger, #b91c1c);
  }

  /* Error messages stay hidden until the field before them is invalid */
  .error {
    display: none;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--color-danger, #b91c1c);
  }
  .field:user-invalid ~ .error {
    display: block;
  }

  .choice {
    margin-right: 0.5rem;
    accent-color: var(--color-brand, #880015);
  }

  button.link,
  button.footer-link,
  button.btn,
  button.btn-outline {
    cursor: pointer;
  }

  /* --- Cookie banner */
  .cookie-banner {
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.4s, visibility 0.4s;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 40;
    border-top: 4px solid var(--color-brand, #880015);
    background: var(--color-surface, #fff);
    box-shadow: 0 -4px 12px rgb(0 0 0 / 0.1);
  }
  .cookie-banner.is-visible {
    visibility: visible;
    opacity: 1;
  }

  /* --- Legal notices */
  .notice {
    width: calc(100% - 2rem);
    max-width: 42rem;
    max-height: 85vh;
    margin: auto;
    border-radius: 0.5rem;
    background: var(--color-surface, #fff);
    color: var(--color-ink, #1a1a1a);
  }
  .notice::backdrop {
    background: rgb(0 0 0 / 0.5);
  }
  .notice-body {
    padding: 1.5rem;
  }
  .notice-body h3 {
    margin-top: 1.25rem;
    font-family: var(--font-serif, Georgia, serif);
    font-size: 1.25rem;
  }
  .notice-body p,
  .notice-body ul {
    margin-top: 0.5rem;
  }
  .notice-body ul {
    padding-left: 1.5rem;
    list-style: disc;
  }
  .notice-actions {
    position: sticky;
    bottom: 0;
    border-top: 1px solid color-mix(in srgb, var(--color-ink, #1a1a1a) 10%, transparent);
    background: var(--color-surface, #fff);
    padding: 1rem 1.5rem;
    text-align: right;
  }

  /* --- YouTube and Google Maps */
  .embed {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 0.5rem;
    background: #1a1a1a; /* always dark, even in dark mode, so the white text on it stays readable */
  }
  .embed iframe {
    width: 100%;
    height: 100%;
    border: 0;
  }
  .embed-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem;
    text-align: center;
    color: #fff;
  }
  .embed-notice {
    border-color: #fff;
    color: #fff;
  }
  @media (max-width: 40rem) {
    .embed-map {
      aspect-ratio: 4 / 3;
    }
  }

  /* --- Booking confirmation */
  .status {
    margin-top: 1.5rem;
    border-left: 4px solid var(--color-success, #15803d);
    border-radius: 0.375rem;
    background: var(--color-success-light, #f0fdf4);
    padding: 1rem 1.25rem;
  }
  .status:empty {
    display: none;
  }
}

/* notifications */
.notification-container {
  position: fixed;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  z-index: 50;

  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;

  background: var(--color-surface, #fff);
  color: var(--color-ink, #1c1917);
  border-radius: 0.5rem;
  box-shadow:
    0 10px 25px -5px rgb(0 0 0 / 0.15),
    0 4px 10px -4px rgb(0 0 0 / 0.1);

  animation:
    notif-in 0.25s ease-out,
    notif-out 0.25s ease-in 2.75s forwards;
}

@media (min-width: 40rem) {
  .notification-container {
    left: auto;
    max-width: 22rem;
  }
}

.notification-container img.notif-child {
  flex-shrink: 0;
}

/* the bag icon is black, so make it white in dark mode */
[data-theme="dark"] .notification-container img.notif-child {
  filter: invert(1);
}

.notification-container p.notif-child {
  margin: 0;
  font-weight: 600;
}

@keyframes notif-in {
  from { opacity: 0; transform: translateY(-0.5rem); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes notif-out {
  to { opacity: 0; transform: translateY(-0.5rem); }
}

@media (prefers-reduced-motion: reduce) {
  .notification-container { animation: none; }
  .cookie-banner { transition: none; }
}