/* ===== Layout: Main, Grid, Footer ===== */

/* Main content */
.site-main {
  margin: 0 auto;
  padding: 0;
}

/* Quiz sub-item */
.card-sub--quiz,
.card--expandable.is-open .card-sub--quiz {
  cursor: default;
  padding: 0;
}

.card-sub--quiz:hover {
  background: var(--color-bg);
}

.quiz {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  height: 100%;
}

.quiz-question-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border-right: 1px solid currentColor;
  gap: 0.5rem;
}

.quiz-cat {
  font-family: var(--font-body);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.45;
  color: inherit;
}

.quiz-question {
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: -0.03em;
  color: inherit;
  text-align: center;
}

.quiz-options {
  display: flex;
  flex-direction: column;
}

.quiz-option {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: -0.03em;
  color: inherit;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: opacity 0.15s ease;
}

.quiz-option + .quiz-option {
  border-top: 1px solid currentColor;
}

.quiz-option:hover {
  opacity: 0.5;
}

/* Quiz response animation */
.quiz-option.is-wrong {
  animation: quizShake 0.4s ease;
}

.quiz-option.is-correct {
  animation: quizPulse 0.4s ease;
}

.quiz-option.is-revealed {
  cursor: default;
  opacity: 0.4;
  pointer-events: none;
}

.quiz-option.is-revealed.is-wrong {
  opacity: 1;
  pointer-events: auto;
  cursor: default;
  background: rgba(200, 50, 50, 0.15);
  color: inherit;
}

.quiz-option.is-revealed.is-correct {
  opacity: 1;
  pointer-events: auto;
  cursor: default;
  background: rgba(50, 160, 70, 0.15);
  color: inherit;
}

.quiz-option a {
  color: inherit;
  text-decoration: underline;
  pointer-events: auto;
  cursor: pointer;
}

@keyframes quizShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

@keyframes quizPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

/* Content grid — 2 columns, table-like shared borders */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-left: 1px solid var(--color-text-primary);
  border-top: 1px solid var(--color-text-primary);
  transition: border-color var(--transition-speed) ease;
}

/* Card base — all cards same size */
.card {
  background: var(--color-bg);
  border: none;
  border-right: 1px solid var(--color-text-primary);
  border-bottom: 1px solid var(--color-text-primary);
  min-height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  text-decoration: none;
  color: var(--color-text-primary);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition:
    background-color var(--transition-speed) ease,
    color var(--transition-speed) ease,
    border-color var(--transition-speed) ease;
}

/* Card title — centered in closed state */
.card-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: var(--font-heading-weight, 400);
  font-stretch: var(--font-heading-stretch, normal);
  line-height: 1.2;
  letter-spacing: -0.05em;
  color: var(--color-text-primary);
  padding: 2.5rem 2rem;
  z-index: 1;
  transition: color var(--transition-speed) ease;
}

/* Direct link cards */
.card--link:hover {
  background: var(--color-surface);
}

.card--link:hover .card-title {
  color: var(--color-accent);
}

/* Expandable cards — sub-items hidden by default */
.card--expandable {
  cursor: pointer;
}

.card--expandable:hover {
  background: var(--color-surface);
}

.card--expandable:hover .card-title {
  color: var(--color-accent);
}

/* Sub-items container — hidden, fills the card when open */
.card-subs {
  display: none;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

/* When card is open: hide title, show subs filling full height */
.card--expandable.is-open .card-title {
  display: none;
}

.card--expandable.is-open .card-subs {
  display: flex;
}

.card--expandable.is-open {
  cursor: default;
}

.card--expandable.is-open:hover {
  background: var(--color-bg);
}

/* Individual sub-item — vertical row inside the card */
.card-sub {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 0 1.5rem;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: -0.03em;
  color: var(--color-text-primary);
  text-decoration: none;
  background: var(--color-bg);
  border: none;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.card-sub + .card-sub {
  border-top: 1px solid var(--color-text-primary);
}

.card-sub:hover {
  background: var(--color-surface);
  color: var(--color-accent);
}

.card-sub a {
  color: inherit;
  text-decoration: none;
  pointer-events: auto;
  cursor: pointer;
}

/* Text-heavy sub-items — block text instead of flex centering */
.card-sub--text {
  display: block;
  padding: 1.5rem;
  line-height: 1.5;
  text-align: left;
  cursor: default;
}

/* Farben card — 2-column grid instead of vertical list */
.card-subs--grid {
  display: none;
  flex-direction: unset;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr 1fr;
  width: 100%;
  height: 100%;
}

.card--expandable.is-open .card-subs--grid {
  display: grid;
}

.card-subs--grid .card-sub {
  border: none;
}

.card-subs--grid .card-sub + .card-sub {
  border-top: none;
}

/* Grid gaps as border lines, matching the outer grid */
.card-subs--grid {
  gap: 0;
  background: var(--color-bg);
  border-collapse: collapse;
}

.card-subs--grid .card-sub {
  border: none;
  border-right: 1px solid var(--color-text-primary);
  border-bottom: 1px solid var(--color-text-primary);
}

.card-subs--grid .card-sub:nth-child(2n) {
  border-right: none;
}

.card-subs--grid .card-sub:nth-last-child(-n+2) {
  border-bottom: none;
}

/* 3×2 grid variant (e.g. Farben with 6 themes) */
.card-subs--3x2 {
  grid-template-rows: 1fr 1fr 1fr;
}

/* 1×3 grid variant (e.g. Stimmung with 3 moods) */
.card-subs--1x3 {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr;
}
.card-subs--1x3 .card-sub,
.card-subs--1x3 .card-sub:nth-child(2n),
.card-subs--1x3 .card-sub:nth-last-child(-n+2) {
  border-bottom: none;
  border-right: 1px solid var(--color-text-primary);
}
.card-subs--1x3 .card-sub:last-child {
  border-right: none;
}

/* 1×2 grid variant (e.g. Farben with 2 categories) */
.card-subs--1x2 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
}
.card-subs--1x2 .card-sub,
.card-subs--1x2 .card-sub:nth-child(2n),
.card-subs--1x2 .card-sub:nth-last-child(-n+2) {
  border-bottom: none;
  border-right: 1px solid var(--color-text-primary);
}
.card-subs--1x2 .card-sub:last-child {
  border-right: none;
}

/* 2×2 grid variant (e.g. Musik von Oehl) */
.card-subs--2x2 {
  grid-template-rows: 1fr 1fr;
}

/* === Third level: sub-sub items === */

/* Expandable sub-item — shows label, hides subsubs */
.card-sub--expandable {
  position: relative;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
}

.card-sub--expandable .card-sub-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 1rem;
}

.card-subsubs {
  display: none;
}

/* When sub is open: hide label, show subsubs */
.card-sub--expandable.is-subsub-open .card-sub-label {
  display: none;
}

.card-sub--expandable.is-subsub-open .card-subsubs {
  display: grid;
}

.card-subsubs--grid {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  width: 100%;
  height: 100%;
  gap: 0;
}

.card-subsub {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: inherit;
  text-decoration: none;
  background: transparent;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s ease;
}

.card-subsub:hover {
  opacity: 0.6;
}

/* Inner dividers for 2×2 subsub grids — simple cross pattern */
.card-subsubs--grid > :nth-child(1) { border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; }
.card-subsubs--grid > :nth-child(2) { border-bottom: 1px solid currentColor; }
.card-subsubs--grid > :nth-child(3) { border-right: 1px solid currentColor; }
/* :nth-child(4) gets no divider borders */

/* 1×2 subsub grid variant — stacked with horizontal divider */
.card-subsubs--1x2 {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr 1fr;
}

.card-subsubs--1x2 .card-subsub {
  border-right: none !important;
}

.card-subsubs--1x2 .card-subsub:first-child {
  border-bottom: 1px solid currentColor;
}

.card-subsubs--1x2 .card-subsub:last-child {
  border-bottom: none;
}

/* 1×3 subsub grid variant — 3 stacked rows */
.card-subsubs--1x3 {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr 1fr 1fr;
}

.card-subsubs--1x3 .card-subsub {
  border-right: none !important;
  border-bottom: 1px solid currentColor;
}

.card-subsubs--1x3 .card-subsub:last-child {
  border-bottom: none;
}

/* 1×4 subsub grid variant — 4 stacked rows */
.card-subsubs--1x4 {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr 1fr 1fr 1fr;
}

.card-subsubs--1x4 .card-subsub {
  border-right: none !important;
  border-bottom: 1px solid currentColor;
}

.card-subsubs--1x4 .card-subsub:last-child {
  border-bottom: none;
}

/* Alternate-color cards (third color in 3-color themes) */
.card--alt {
  background: var(--color-card-alt);
  border-color: var(--color-card-alt-text);
}

.card--alt .card-title {
  color: var(--color-card-alt-text);
}

.card--alt:hover {
  background: var(--color-card-alt);
  opacity: 0.9;
}

.card--alt:hover .card-title {
  color: var(--color-card-alt-text);
}

.card--alt.card--expandable.is-open:hover {
  background: var(--color-card-alt);
}

.card--alt .card-sub {
  background: var(--color-card-alt);
  color: var(--color-card-alt-text);
}

.card--alt .card-sub + .card-sub {
  border-color: var(--color-card-alt-text);
}

.card--alt .card-sub:hover {
  background: var(--color-card-alt);
  opacity: 0.85;
}

.card--alt .card-subs--grid .card-sub {
  border-color: var(--color-card-alt-text);
}

/* Sub-items use accent color when card is open (for themes with 3rd color on subs) */
.card--expandable.is-open .card-sub {
  background: var(--color-sub-bg);
  color: var(--color-sub-text);
}

.card--expandable.is-open .card-sub + .card-sub {
  border-color: var(--color-sub-border);
}

.card--expandable.is-open .card-subs--grid .card-sub {
  border-color: var(--color-sub-border);
}

.card--expandable.is-open .card-sub:hover {
  background: var(--color-sub-bg);
  opacity: 0.85;
}

.card--expandable.is-open .card-subsub {
  color: var(--color-sub-text);
}

/* === Per-card colors for Lebhaft themes === */
/* Each card in the grid picks up its own color from --color-card-N */
.content-grid > :nth-child(1) { background: var(--color-card-1); color: var(--color-card-text-1); }
.content-grid > :nth-child(2) { background: var(--color-card-2); color: var(--color-card-text-2); }
.content-grid > :nth-child(3) { background: var(--color-card-3); color: var(--color-card-text-3); }
.content-grid > :nth-child(4) { background: var(--color-card-4); color: var(--color-card-text-4); }
.content-grid > :nth-child(5) { background: var(--color-card-1); color: var(--color-card-text-1); }
.content-grid > :nth-child(6) { background: var(--color-card-2); color: var(--color-card-text-2); }
.content-grid > :nth-child(7) { background: var(--color-card-3); color: var(--color-card-text-3); }
.content-grid > :nth-child(8) { background: var(--color-card-4); color: var(--color-card-text-4); }
.content-grid > :nth-child(9) { background: var(--color-card-1); color: var(--color-card-text-1); }
.content-grid > :nth-child(10) { background: var(--color-card-2); color: var(--color-card-text-2); }

/* Card titles inherit per-card text color */
.content-grid > :nth-child(1) .card-title { color: var(--color-card-text-1); }
.content-grid > :nth-child(2) .card-title { color: var(--color-card-text-2); }
.content-grid > :nth-child(3) .card-title { color: var(--color-card-text-3); }
.content-grid > :nth-child(4) .card-title { color: var(--color-card-text-4); }
.content-grid > :nth-child(5) .card-title { color: var(--color-card-text-1); }
.content-grid > :nth-child(6) .card-title { color: var(--color-card-text-2); }
.content-grid > :nth-child(7) .card-title { color: var(--color-card-text-3); }
.content-grid > :nth-child(8) .card-title { color: var(--color-card-text-4); }
.content-grid > :nth-child(9) .card-title { color: var(--color-card-text-1); }
.content-grid > :nth-child(10) .card-title { color: var(--color-card-text-2); }

/* Card borders use per-card text color */
.content-grid > :nth-child(1) { border-color: var(--color-card-text-1); }
.content-grid > :nth-child(2) { border-color: var(--color-card-text-2); }
.content-grid > :nth-child(3) { border-color: var(--color-card-text-3); }
.content-grid > :nth-child(4) { border-color: var(--color-card-text-4); }
.content-grid > :nth-child(5) { border-color: var(--color-card-text-1); }
.content-grid > :nth-child(6) { border-color: var(--color-card-text-2); }
.content-grid > :nth-child(7) { border-color: var(--color-card-text-3); }
.content-grid > :nth-child(8) { border-color: var(--color-card-text-4); }
.content-grid > :nth-child(9) { border-color: var(--color-card-text-1); }
.content-grid > :nth-child(10) { border-color: var(--color-card-text-2); }

/* Active theme button highlight */
.card-subs--grid .theme-btn.is-active {
  font-weight: 500;
}

/* External icon */
.external-icon {
  font-size: 0.6em;
  margin-left: 0.25em;
  opacity: 0.5;
}

/* ===== Newsletter form ===== */
.newsletter-form {
  display: none;
  align-items: stretch;
  gap: 0;
  margin-top: 1rem;
  border-top: none;
}
.card--expandable.is-open .newsletter-form {
  display: flex;
}
.newsletter-msg {
  display: none;
}
.card--expandable.is-open .newsletter-msg:not(:empty) {
  display: block;
}
.newsletter-input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--color-text-primary);
  background: transparent;
  border: none;
  border-right: 1px solid var(--color-text-primary);
  outline: none;
}
.newsletter-input::placeholder {
  color: var(--color-text-primary);
  opacity: 0.5;
}
.newsletter-btn {
  padding: 0.6rem 1rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--color-text-primary);
  background: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
  transition: opacity 0.15s ease;
}
.newsletter-btn:hover {
  opacity: 0.6;
}
.newsletter-msg:not(:empty) {
  font-family: var(--font-body);
  font-size: 0.7rem;
  text-align: center;
  padding: 0.5rem 0.75rem;
  margin: 0;
  color: var(--color-text-primary);
}

/* Footer */
.site-footer {
  margin: 0;
  padding: 2rem 1.5rem;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  text-align: center;
}

/* ===== Essay Theme — continuous gradient across cards ===== */
/* Each card + body shares the same fixed gradient so the color flows seamlessly */
[data-theme="essay"] body {
  background: linear-gradient(to bottom, #fe4400 0%, #fe4400 25%, #f5f0eb 100%) fixed !important;
}

[data-theme="essay"] .content-grid {
  background: transparent;
  border-color: #121212;
}

[data-theme="essay"] .card {
  background: linear-gradient(to bottom, #fe4400 0%, #fe4400 25%, #f5f0eb 100%) fixed !important;
}

[data-theme="essay"] .card-sub {
  background: linear-gradient(to bottom, #fe4400 0%, #fe4400 25%, #f5f0eb 100%) fixed !important;
}

[data-theme="essay"] .card-subs--grid {
  background: linear-gradient(to bottom, #fe4400 0%, #fe4400 25%, #f5f0eb 100%) fixed !important;
}

/* All text and borders black */
[data-theme="essay"] .content-grid {
  border-color: #121212;
}

[data-theme="essay"] .card {
  color: #121212;
  border-color: #121212 !important;
}

[data-theme="essay"] .card-title {
  color: #121212;
}

[data-theme="essay"] .card-sub {
  color: #121212;
  border-color: #121212 !important;
}

[data-theme="essay"] .card-subsub {
  color: #121212;
}

[data-theme="essay"] .site-footer {
  background: transparent;
  color: #121212;
}

/* ===== Roto Roto — image flash overlay ===== */
.roto-flash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: url(/assets/bilder/deathandtaxes.jpg) center / cover no-repeat;
  pointer-events: none;
  opacity: 0;
  transition: none;
}

.roto-flash.is-visible {
  opacity: 1;
}

/* ===== Spagat Theme — background image ===== */
body.spagat-bg {
  background: url(/assets/bilder/Spagat_BG2.jpg) center / cover fixed no-repeat !important;
  transition: background-position 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

/* Spagat — keep lines, transparent backgrounds */
[data-theme="spagat"] .content-grid {
  background: transparent;
  position: relative;
}

[data-theme="spagat"] .card {
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

[data-theme="spagat"] .card:hover {
  background: transparent !important;
}

[data-theme="spagat"] .card-sub {
  background: transparent !important;
}

[data-theme="spagat"] .card-sub:hover {
  background: transparent !important;
}

/* Rot-Schwarz — remove all lines, use dots */
[data-theme="rot-schwarz"] .content-grid {
  border: none;
  position: relative;
}

[data-theme="rot-schwarz"] .card {
  border: none !important;
}

[data-theme="rot-schwarz"] .card-sub {
  border: none !important;
}

[data-theme="rot-schwarz"] .card-sub + .card-sub {
  border: none !important;
}

/* Grid dots (for rot-schwarz) */
.theme-dot {
  position: absolute;
  width: 7px;
  height: 7px;
  background: #080808;
  border-radius: 50%;
  z-index: 2;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

[data-theme="spagat"] .site-footer {
  background: transparent;
}

[data-theme="rot-schwarz"] .card-subs--grid .card-sub {
  border: none !important;
}

[data-theme="rot-schwarz"] .card-subsubs {
  border: none !important;
}

[data-theme="rot-schwarz"] .card-subsub {
  border: none !important;
}

[data-theme="spagat"] .card--expandable.is-open {
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

[data-theme="spagat"] .card--expandable.is-open:hover {
  background: transparent !important;
}

[data-theme="spagat"] .card--expandable.is-open .card-sub {
  background: transparent !important;
}

[data-theme="spagat"] .card-subs--grid {
  background: transparent !important;
}

[data-theme="rot-schwarz"] .card-subs--grid {
  border: none !important;
}

[data-theme="rot-schwarz"] .card-subs--grid .card-sub {
  border: none !important;
}
