/* ==========================================================================
   Base reset + typography. Mobile-first: base rules target ~375px width;
   everything scales up via min-width media queries only.
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.5;
  overflow-x: hidden;
}

img,
svg,
video {
  max-width: 100%;
  display: block;
}

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

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

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

a:hover {
  color: var(--color-accent-hover);
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Visible, theme-aware focus ring for keyboard users — never remove outline
   without replacing it. */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: var(--space-3);
}

.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;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-3);
  z-index: 1000;
  background: var(--color-surface);
  color: var(--color-text);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  transition: top var(--transition-fast);
}

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

/* Buttons ------------------------------------------------------------- */

.btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--fs-body);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.btn-ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  transform: scale(0);
  pointer-events: none;
  animation: btn-ripple-expand 550ms ease-out forwards;
}

@keyframes btn-ripple-expand {
  to {
    transform: scale(2.5);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn-ripple {
    display: none;
  }
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.btn-primary:hover {
  background: var(--color-accent-hover);
  color: var(--color-on-accent);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Form fields ----------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  text-align: left;
}

.field label {
  font-size: var(--fs-small);
  color: var(--color-text-muted);
}

.field input,
.field textarea {
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--color-text-muted);
}

.field-error {
  font-size: var(--fs-small);
  color: var(--color-error);
  min-height: 1.2em;
}

.form-status {
  font-size: var(--fs-small);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
}

.form-status[data-state="success"] {
  background: color-mix(in srgb, var(--color-success) 20%, transparent);
  color: var(--color-success);
}

.form-status[data-state="error"] {
  background: color-mix(in srgb, var(--color-error) 20%, transparent);
  color: var(--color-error);
}

/* Shared subscribe-form layout — every template's countdown page uses
   this same shape (stacked on mobile, row from 480px up) so it isn't
   redefined per template. --------------------------------------------- */

.page-form {
  position: relative;
  z-index: 1;
  margin-top: var(--space-6);
  width: 100%;
  max-width: 420px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.page-form-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.page-form-row .field {
  flex: 1;
}

.page-form .btn {
  width: 100%;
}

@media (min-width: 480px) {
  .page-form-row {
    flex-direction: row;
  }

  .page-form .btn {
    width: auto;
    flex-shrink: 0;
  }
}

/* Shared social-links row -------------------------------------------- */

.social-links {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.social-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

.social-links a:hover {
  color: var(--color-text);
  border-color: var(--color-accent);
}

/* Shared page footer --------------------------------------------------- */

.page-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: var(--space-4) var(--space-3);
  font-size: var(--fs-small);
  color: var(--color-text-muted);
}

/* noscript fallback ------------------------------------------------------ */

.noscript-banner {
  background: var(--color-surface);
  color: var(--color-text);
  text-align: center;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--fs-small);
}

/* Shared background-effect canvas (particles/snowfall) -------------------
   Templates position an ancestor `position: relative` and drop this in as
   a decorative first child. Hidden until effects.js marks it drawable, so
   an inert <canvas> never paints as a stray black box. */

.bg-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.bg-canvas:not([data-ready]) {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  /* !important: must win over the inline-equivalent state effects.js sets
     after deciding (independently) that animating is safe to start. */
  .bg-canvas {
    display: none !important;
  }
}
