@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&icon_names=close,menu');

@view-transition {
  navigation: auto;
}

:root {
  --brand: oklch(46% 0.14 145);
  --brand-hover: oklch(38% 0.13 145);
  --brand-soft: oklch(96% 0.03 145);
  --brand-border: oklch(86% 0.05 145);

  --bg: #ffffff;
  --surface: oklch(99% 0.004 145);
  --text: oklch(18% 0.02 145);
  --text-muted: oklch(48% 0.02 145);
  --border: oklch(91% 0.012 145);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px oklch(18% 0.02 145 / 4%), 0 4px 12px -2px oklch(18% 0.02 145 / 6%);
  --shadow-md: 0 2px 4px oklch(18% 0.02 145 / 4%), 0 12px 32px -6px oklch(18% 0.02 145 / 8%);
  --shadow-lg: 0 4px 8px oklch(18% 0.02 145 / 5%), 0 20px 40px -12px oklch(18% 0.02 145 / 12%);

  --container: min(100% - 2.5rem, 52rem);
  --container-wide: min(100% - 2.5rem, 64rem);

  interpolate-size: allow-keywords;
}

/* ==========================================================================
   1. Base & Reset
   ========================================================================== */

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

html {
  width: 100%;
  height: 100%;
  overflow: hidden scroll;
  scroll-behavior: smooth;
  color: var(--text);
  background-color: var(--bg);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

body {
  width: 100%;
  min-height: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  grid-template-columns: 100%;
}

/* ==========================================================================
   2. Typography & Inline Elements
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  letter-spacing: -0.025em;
  text-wrap: balance;
  color: var(--text);
}

h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 800;
  margin-block: 0.5rem 1.5rem;
}

h2 {
  font-size: clamp(1.35rem, 2.5vw, 1.65rem);
  font-weight: 700;
  margin-block: 2rem 0.75rem;
}

h3 {
  font-size: clamp(1.1rem, 1.8vw, 1.25rem);
  font-weight: 650;
  margin-block: 1.5rem 0.5rem;
}

p {
  text-wrap: pretty;
}

p + p {
  margin-top: 1rem;
}

ul, ol {
  padding-left: 1.5rem;
  margin-block: 0.75rem;
}

li + li {
  margin-top: 0.35rem;
}

main a {
  color: var(--brand);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

main a:hover {
  color: var(--brand-hover);
  text-decoration-thickness: 2px;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
  background: var(--brand-soft);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin-block: 2.25rem;
}

.post-meta {
  color: var(--text-muted);
  font-size: 0.925rem;
  margin-top: -1rem;
  margin-bottom: 1.75rem;
}

/* ==========================================================================
   3. Layout Regions (Header, Nav, Main, Footer)
   ========================================================================== */

canvas#background {
  touch-action: none;
  position: fixed;
  top: 0;
  width: 100%;
  height: 75%;
  z-index: -10;
}

body > header {
  width: var(--container-wide);
  margin-inline: auto;
  padding-top: 2rem;
}

#hero {
  width: 100%;
  display: block;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

body > nav {
  width: var(--container-wide);
  margin: 1.25rem auto;
  top: 1rem;
  position: sticky;
  display: flex;
  flex-flow: row nowrap;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem;
  border-radius: var(--radius-md);
  background: oklch(100% 0 0 / 78%);
  backdrop-filter: saturate(180%) blur(16px);
  border: 1px solid oklch(18% 0.02 145 / 8%);
  box-shadow: var(--shadow-sm);
  z-index: 100;
  font-weight: 600;
  font-size: 0.95rem;
}

nav a {
  position: relative;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text);
  transition: background-color 0.18s ease, color 0.18s ease;
}

#nav-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 750;
  letter-spacing: -0.01em;
}

#nav-logo img {
  height: 20px;
  width: auto;
  border-radius: 0;
}

nav a:hover {
  background: oklch(46% 0.14 145 / 8%);
  color: var(--brand);
}

nav a[aria-current="page"] {
  background: oklch(46% 0.14 145 / 12%);
  color: var(--brand-hover);
}

nav .mobile-nav {
  display: none;
}

body > main {
  background: linear-gradient(to bottom, #fff0 0%, var(--bg) 6rem);
  padding-block: 1.5rem 4rem;
}

body > main > * {
  width: var(--container);
  margin-inline: auto;
}

body > footer {
  width: 100%;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 2rem max((100% - 52rem) / 2, 1.25rem);
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ==========================================================================
   4. Media, Figures & Collapsible Details
   ========================================================================== */

img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  display: block;
}

main p > img,
main p > a > img {
  margin-block: 1rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

img.max-30 { max-width: 30%; }
img.max-50 { max-width: 50%; }

figure {
  margin-block: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  box-shadow: var(--shadow-sm);
}

figure p {
  margin: 0;
}

figure img {
  width: 100%;
  border-radius: var(--radius-sm);
}

figcaption {
  margin-top: 0.65rem;
  padding-inline: 0.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
}

details {
  margin-block: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

summary {
  list-style: none;
  cursor: pointer;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  transition: background-color 0.15s ease;
}

summary::-webkit-details-marker {
  display: none;
}

summary:hover {
  background: var(--surface);
}

summary > h2 {
  display: inline;
  margin: 0;
  font-size: 1.25rem;
}

summary::after {
  content: "+";
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--brand);
  line-height: 1;
  transition: transform 0.25s ease;
}

details[open] > summary {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

details[open] > summary::after {
  transform: rotate(45deg);
}

details::details-content {
  padding-inline: 1.5rem;
  transition: height 0.3s ease, opacity 0.3s ease, content-visibility 0.3s ease allow-discrete;
  height: 0;
  opacity: 0;
}

details[open]::details-content {
  padding-block: 1.25rem 1.5rem;
  height: auto;
  opacity: 1;
}

/* Fallback padding when ::details-content is unsupported */
@supports not selector(::details-content) {
  details > :not(summary) {
    padding-inline: 1.5rem;
  }
  details[open] {
    padding-bottom: 1.25rem;
  }
}

/* ==========================================================================
   5. Custom Components (Banner, Flex, Cards, Vuoden Ressut Carousel)
   ========================================================================== */

.external-form {
  width: 100%;
  height: 150vh;
}

article.banner {
  margin-block: 1.5rem 2.25rem;
  padding: 1.75rem 2rem;
  background-color: var(--brand-soft);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-md);
}

article.banner > :first-child {
  margin-top: 0;
}

section.flex {
  display: flex;
  flex-flow: column nowrap;
  gap: 1.25rem;
  margin-block: 1.75rem;
}

article.card {
  display: flow-root;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1.75rem 2rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

article.card > :first-child {
  margin-top: 0;
}

/* Interactive cards on /uutiset and /tapahtumat */
article.card:has(> h2 > a):hover,
article.card:has(> h3 > a):hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand-border);
}

article.card > h2 > a,
article.card > h3 > a {
  color: var(--text);
  text-decoration: none;
}

article.card > h2 > a:hover,
article.card > h3 > a:hover {
  color: var(--brand);
}

article.card > .post-meta {
  margin: 0.35rem 0 0 0;
}

article.card > :last-child {
  margin-bottom: 0;
}

/* Events metadata and tags */
.event-meta {
  color: var(--text-muted);
  font-size: 0.925rem;
  margin-block: 0.25rem 0.75rem;
}

main > h1 + .event-meta {
  margin-top: -1rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-block: 0.5rem 1rem;
}

main > h1 + .tags {
  margin-top: -0.75rem;
  margin-bottom: 1.5rem;
}

main > h1 + .event-meta + .tags {
  margin-top: -0.25rem;
  margin-bottom: 1.5rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  color: var(--brand-hover);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
}

/* Vuoden Ressut Stacking Carousel & Portrait Layout */
section.carousel {
  gap: 1.75rem;
  perspective: 1000px;
}

.carousel article.card {
  position: relative;
  padding: 2rem 2.25rem;
  box-shadow: var(--shadow-md);
  transform-origin: center top;
  will-change: transform, opacity;
}

.carousel article.card > h2 {
  padding-bottom: 0.85rem;
  margin-bottom: 1.15rem;
  border-bottom: 1px solid var(--border);
}

/* Modern floating portrait frame inside Vuoden Ressut cards */
.carousel article.card > p:has(> img) {
  float: right;
  width: clamp(140px, 26%, 200px);
  margin: 0.15rem 0 1rem 1.75rem;
}

.carousel article.card > p > img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: center 15%;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}

/* Keep landscape group/duo photos in natural aspect ratio */
.carousel article.card > p > img[src*="2025-pasi-siitonen"],
.carousel article.card > p > img[src*="2014-laura-raty"],
.carousel article.card > p > img[src*="2011-kaarlo-tuori"],
.carousel article.card > p > img[src*="2009-jukka-kuoppamaki"],
.carousel article.card > p > img[src*="2006-harri-dahlstrom"] {
  aspect-ratio: 4 / 3;
  object-position: center;
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .carousel article.card {
      animation: card-stack linear both;
      animation-timeline: view();
    }
  }
}

@keyframes card-stack {
  entry 0% {
    opacity: 0;
    transform: translateY(28px) scale(0.95);
  }
  entry 45% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  exit 15% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  exit 100% {
    opacity: 0.15;
    transform: translateY(48px) scale(0.92);
  }
}

/* ==========================================================================
   6. Widgets & Registration Box
   ========================================================================== */

.widget {
  margin-block: 2rem;
  padding: 1.75rem 2rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.widget-header > h2 {
  margin-top: 0;
  margin-bottom: 0.35rem;
}

.widget-header > .event-meta {
  margin-top: 0;
  margin-bottom: 1rem;
}

.widget-steps {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 1.5rem 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.widget-step {
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

.widget-step.is-active {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand-hover);
}

.widget-step.is-done {
  border-color: var(--brand-border);
  color: var(--brand);
}

.widget-lead {
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.quota-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.quota-card {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.quota-card:hover:not(.is-full) {
  border-color: var(--brand-border);
  box-shadow: var(--shadow-sm);
}

.quota-card.is-selected {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.quota-card.is-full {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--surface);
}

.quota-card input[type="radio"] {
  margin-top: 0.25rem;
  accent-color: var(--brand);
}

.quota-card-body {
  flex: 1;
  min-width: 0;
}

.quota-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.quota-price {
  font-weight: 700;
  color: var(--brand-hover);
  white-space: nowrap;
}

.quota-desc {
  margin-top: 0.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.quota-remaining {
  display: inline-block;
  margin-top: 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand-hover);
}

.quota-remaining.is-full {
  color: oklch(45% 0.18 25);
}

.selected-quota-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  font-size: 0.925rem;
}

.widget-form {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.field-group {
  border: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-group > label,
.field-group > legend {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.req {
  color: oklch(48% 0.18 25);
}

.field-help {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.field-group input[type="text"],
.field-group input[type="email"],
.field-group input[type="tel"],
.field-group input[type="number"],
.field-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-group input:focus,
.field-group textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px oklch(46% 0.14 145 / 15%);
}

.field-error {
  margin: 0;
  font-size: 0.85rem;
  color: oklch(45% 0.18 25);
  font-weight: 500;
}

.choice-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.choice-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.choice-card:hover {
  border-color: var(--brand-border);
}

.choice-card.is-selected {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.choice-card input {
  accent-color: var(--brand);
}

.choice-label {
  flex: 1;
}

.choice-price {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.donation-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.donation-btn {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.donation-btn:hover {
  border-color: var(--brand-border);
}

.donation-btn.is-selected {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-hover);
}

.donation-custom {
  margin-top: 0.4rem;
}

.donation-custom.is-hidden {
  display: none;
}

.price-summary {
  padding: 1rem 1.15rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.price-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.925rem;
  color: var(--text-muted);
}

.price-row--total {
  margin-top: 0.25rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 1rem;
  color: var(--text);
}

.widget-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.btn {
  font: inherit;
  font-weight: 650;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.btn-primary {
  padding: 0.65rem 1.35rem;
  background: var(--brand);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover);
}

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

.btn-link {
  padding: 0.25rem 0.4rem;
  background: transparent;
  color: var(--brand);
  text-decoration: underline;
  font-size: 0.875rem;
}

.btn-link:hover {
  color: var(--brand-hover);
}

.widget-notice {
  padding: 1rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 1rem;
}

.widget-notice--error {
  border-color: oklch(75% 0.14 25);
  background: oklch(97% 0.02 25);
  color: oklch(38% 0.16 25);
}

.widget-notice--success {
  border-color: var(--brand-border);
  background: var(--brand-soft);
}

.widget-notice > h3,
.reservation-summary > h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.reservation-summary {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.reservation-summary > .event-meta {
  margin: 0;
}

.stripe-checkout-mount {
  padding: 1.5rem;
  border: 2px dashed var(--brand-border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-align: center;
}

.stripe-checkout-mount.is-mounted {
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.stripe-checkout-mount > .event-meta {
  margin: 0;
}

/* ==========================================================================
   7. Responsive / Mobile Layout (< 768px)
   ========================================================================== */

@media (width < 768px) {
  body > header {
    display: none;
  }

  body > nav {
    width: 100%;
    margin: 0;
    border-radius: 0;
    border-inline: 0;
    border-top: 0;
    top: 0;
    min-height: 52px;
    padding: 0 1.25rem;
  }

  body > nav .mobile-nav {
    position: fixed;
    display: grid;
    place-content: center;
    top: 14px;
    right: 1.25rem;
    width: 24px;
    height: 24px;
  }

  body > nav input[type="checkbox"] {
    width: 24px;
    height: 24px;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
  }

  body > nav .mobile-nav::before {
    content: 'menu';
    font-size: 24px;
    line-height: 24px;
    position: absolute;
    font-family: 'Material Symbols Outlined';
    color: var(--text);
  }

  body > nav:not(:has(input:checked)) a:not(:first-child) {
    display: none;
  }

  body > nav .mobile-nav:has(input:checked)::before {
    content: 'close';
  }

  body > nav:has(input:checked) {
    position: fixed;
    inset: 0;
    height: 100dvh;
    padding: 4rem 1.5rem 35dvh;
    font-size: 1.35rem;
    flex-flow: column nowrap;
    justify-content: space-evenly;
    background: oklch(100% 0 0 / 92%);
  }

  article.card,
  .carousel article.card,
  article.banner,
  .widget {
    padding: 1.35rem 1.25rem;
  }

  .widget-steps {
    grid-template-columns: 1fr;
  }

  .carousel article.card > p:has(> img) {
    float: none;
    width: min(100%, 220px);
    margin: 0 auto 1.25rem auto;
  }
}
