/* ==========================================================================
   KuKi - Josef Fabri Bestattungen GmbH
   Design System & Magnolia Theme Styles
   ========================================================================== */

:root {
  --color-primary: #6B3F5E;
  --color-primary-hover: #5A324E;
  --color-primary-container: #F4D5E8;
  --color-secondary: #8B6380;
  --color-secondary-hover: #78526E;
  --color-secondary-container: #EDD5E8;
  --color-background: #FAF7F5;
  --color-surface: #FAF7F5;
  --color-surface-variant: #F2EAED;
  --color-surface-container: #FFFFFF;
  --color-on-background: #1E1218;
  --color-on-surface-variant: #4A2E3F;
  --color-outline: #E2D0DA;
  --color-outline-focus: #6B3F5E;
  --color-footer: #784987;
  --color-footer-text: #FFFFFF;
  --color-success: #2E7D32;
  --color-error: #C62828;
  --max-content-width: 960px;
}

/* Base resets & typography */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--color-on-background);
  background-color: var(--color-background);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  scroll-padding-top: 80px;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--color-background);
  position: relative;
}

/* Global Typography & Hyphenation defaults */
p {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  text-wrap: pretty;
  overflow-wrap: break-word;
  word-break: normal;
  text-align-last: left;
}

h1, h2, h3, h4, h5, h6 {
  text-wrap: balance;
  hyphens: manual;
  -webkit-hyphens: manual;
  -ms-hyphens: manual;
  overflow-wrap: break-word;
}

/* Background Blossom Overlay */
.bg-blossom-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  background-image: url('/images/magnolie_bluete.png');
  background-repeat: no-repeat;
  background-position: top center;
  background-size: cover;
  opacity: 0.22;
  mix-blend-mode: multiply;
  filter: contrast(1.05) saturate(1.1);
}

/* Layout Shell */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: rgba(250, 247, 245, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-outline);
  width: 100%;
}

.header-container {
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

/* Left: Logo */
.header-brand-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.header-logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.header-logo-link:hover {
  transform: scale(1.04);
}

.header-logo-circle {
  width: 52px;
  height: 52px;
  background-color: #ffffff;
  border: 1px solid var(--color-outline);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-logo {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Center: Typography */
.header-titles {
  flex: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 0.5rem;
}

.header-title-main {
  font-size: 1.22rem;
  font-weight: 700;
  color: var(--color-on-background);
  letter-spacing: 0.08em;
  line-height: 1.2;
}

.header-title-sub {
  font-size: 0.78rem;
  color: #382335;
  letter-spacing: 0.04em;
  margin-top: 3px;
  line-height: 1.2;
}

/* Right: Menu Button & Floating Dropdown */
.header-nav-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.nav-dropdown-wrapper {
  position: relative;
}

.nav-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--color-primary);
  padding: 0.45rem;
  border-radius: 8px;
  transition: background-color 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
}

.nav-menu-btn:hover {
  background-color: var(--color-surface-variant);
  border-color: var(--color-outline);
}

.nav-menu-btn:active {
  transform: scale(0.96);
}

.nav-menu-icon {
  width: 28px;
  height: 28px;
  color: var(--color-primary);
}

/* Floating Dropdown Panel */
.nav-dropdown-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background-color: #ffffff;
  border: 1px solid var(--color-outline);
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.06);
  padding: 0.4rem 0;
  z-index: 50;
  animation: dropdownFadeIn 0.15s ease-out;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.nav-dropdown-panel.open {
  display: block;
}

.nav-menu-list {
  display: flex;
  flex-direction: column;
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  color: var(--color-on-background);
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-dropdown-item:hover {
  background-color: var(--color-surface-variant);
  color: var(--color-primary);
}

.nav-dropdown-item.active {
  color: var(--color-primary);
  font-weight: 600;
  background-color: rgba(107, 63, 94, 0.07);
}

.nav-check-icon {
  width: 20px;
  display: inline-block;
  color: var(--color-primary);
  font-weight: bold;
}

.nav-item-text {
  flex: 1;
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem 1.25rem;
  scroll-margin-top: 80px;
}

/* Footer */
.app-footer {
  position: sticky;
  bottom: 0;
  z-index: 30;
  background-color: var(--color-footer);
  color: var(--color-footer-text);
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.08);
  width: 100%;
}

.footer-container {
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--color-footer-text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  transition: background 0.2s;
  min-width: 90px;
  justify-content: center;
}

.footer-nav-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.footer-nav-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.footer-phone-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: #ffffff;
  color: var(--color-footer);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.5rem 1.1rem;
  border-radius: 9999px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.footer-phone-btn:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Component Styles: Cards, Typography, Forms */
.page-content {
  animation: pageFadeIn 0.3s ease-out;
}

@keyframes pageFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-header {
  margin-bottom: 1.75rem;
}

.page-title {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.page-lead {
  font-size: 1.05rem;
  color: var(--color-on-surface-variant);
  line-height: 1.7;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  text-wrap: pretty;
  overflow-wrap: break-word;
  text-align-last: left;
}

.card {
  background-color: var(--color-surface-container);
  border: 1px solid var(--color-outline);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 4px rgba(30, 18, 24, 0.04);
}

.section-divider {
  border: 0;
  height: 1px;
  background-color: var(--color-outline);
  margin: 1.75rem 0;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-on-background);
  margin-bottom: 0.35rem;
}

.section-accent-line {
  width: 40px;
  height: 3px;
  background-color: var(--color-primary);
  margin-bottom: 1.25rem;
  border-radius: 2px;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background-color: var(--color-primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Service Accordion Cards */
.services-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}

@media (min-width: 640px) {
  .services-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.service-card {
  background-color: #ffffff;
  border: 1px solid var(--color-outline);
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.service-card:hover {
  border-color: var(--color-secondary);
  box-shadow: 0 4px 12px rgba(107, 63, 94, 0.08);
}

.service-accent-bar {
  height: 4px;
  background-color: var(--color-primary);
}

.service-header {
  padding: 1.15rem 1.25rem;
  cursor: pointer;
  user-select: none;
}

.service-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.service-icon-title {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.service-icon {
  width: 24px;
  height: 24px;
  color: var(--color-primary);
  flex-shrink: 0;
}

.service-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-on-background);
}

.service-chevron {
  width: 20px;
  height: 20px;
  color: var(--color-secondary);
  transition: transform 0.25s ease;
}

.service-card.expanded .service-chevron {
  transform: rotate(180deg);
}

.service-desc {
  font-size: 0.92rem;
  color: var(--color-on-surface-variant);
  line-height: 1.5;
}

.service-details {
  display: block;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding: 0 1.25rem;
  font-size: 0.92rem;
  color: var(--color-on-surface-variant);
  line-height: 1.6;
  border-top: 1px dashed transparent;
  margin-top: 0;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  text-wrap: pretty;
  overflow-wrap: break-word;
  text-align-last: left;
  transition: max-height 0.35s ease, opacity 0.3s ease, padding-top 0.35s ease, padding-bottom 0.35s ease, margin-top 0.35s ease, border-color 0.3s ease;
}

.service-card.expanded .service-details {
  max-height: 600px;
  opacity: 1;
  border-top-color: var(--color-outline);
  padding-top: 0.85rem;
  padding-bottom: 1.25rem;
  margin-top: 0.5rem;
}

/* Team Cards */
.team-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

@media (min-width: 640px) {
  .team-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.team-card {
  background: #ffffff;
  border: 1px solid var(--color-outline);
  border-radius: 8px;
  padding: 1.5rem 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.team-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background-color: var(--color-primary-container);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.35rem;
  margin-bottom: 1rem;
  border: 2px solid var(--color-outline);
}

.team-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--color-on-background);
  margin-bottom: 0.25rem;
}

.team-role {
  font-size: 0.85rem;
  color: var(--color-secondary);
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.team-desc {
  font-size: 0.88rem;
  color: var(--color-on-surface-variant);
  line-height: 1.4;
}

/* Contact Page Layout & Form */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin-top: 1.5rem;
}

@media (min-width: 768px) {
  .contact-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.contact-row {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-outline);
}

.contact-row:last-child {
  border-bottom: none;
}

.contact-row-icon {
  width: 20px;
  height: 20px;
  color: var(--color-primary);
  margin-top: 2px;
  flex-shrink: 0;
}

.contact-row-content {
  display: flex;
  flex-direction: column;
}

.contact-row-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.contact-row-val {
  font-size: 0.95rem;
  color: var(--color-on-surface-variant);
  white-space: pre-line;
}

.form-group {
  margin-bottom: 1.15rem;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-on-surface-variant);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  color: var(--color-on-background);
  background-color: #ffffff;
  border: 1px solid var(--color-outline);
  border-radius: 6px;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(107, 63, 94, 0.15);
}

.form-control.is-invalid {
  border-color: var(--color-error);
}

.invalid-feedback {
  display: block;
  font-size: 0.8rem;
  color: var(--color-error);
  margin-top: 0.3rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background-color: var(--color-primary);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  width: 100%;
}

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

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

/* Alert Boxes */
.alert-success {
  background-color: #E8F5E9;
  border: 1px solid #A5D6A7;
  color: #1B5E20;
  padding: 1rem 1.25rem;
  border-radius: 6px;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.alert-error {
  background-color: #FFEBEE;
  border: 1px solid #EF9A9A;
  color: #B71C1C;
  padding: 1rem 1.25rem;
  border-radius: 6px;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

/* HTMX Swapping transitions */
.htmx-swapping {
  opacity: 0;
  transition: opacity 150ms ease-out;
}

.htmx-settling {
  opacity: 1;
  transition: opacity 150ms ease-in;
}

/* Map & Navigation Section */
.map-embed-container {
  position: relative;
  width: 100%;
  height: 360px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--color-outline);
  background-color: var(--color-surface-variant);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.map-embed-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.nav-services-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.nav-service-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.2s ease;
  border: 1px solid var(--color-outline);
  background-color: #ffffff;
  color: var(--color-primary);
}

.nav-service-btn:hover {
  background-color: var(--color-primary-container);
  border-color: var(--color-primary);
  color: var(--color-primary-hover);
  transform: translateY(-1px);
}

.nav-service-btn svg {
  flex-shrink: 0;
}

/* Accessibility: Respect Reduced Motion preferences */
@media (prefers-reduced-motion: reduce) {
  .page-content,
  .nav-dropdown-panel,
  .service-chevron,
  .service-details,
  .htmx-swapping,
  .htmx-settling {
    animation: none !important;
    transition: none !important;
  }
}

/* Typography & Justification Utilities */
.text-justify {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  text-wrap: pretty;
  overflow-wrap: break-word;
  word-break: normal;
  text-align-last: left;
}

.text-left {
  text-align: left;
  text-align-last: left;
}

.text-center {
  text-align: center;
  text-align-last: center;
}

.hyphens-auto {
  hyphens: auto;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
}

.hyphens-manual {
  hyphens: manual;
  -webkit-hyphens: manual;
  -ms-hyphens: manual;
}

.hyphens-none {
  hyphens: none;
  -webkit-hyphens: none;
  -ms-hyphens: none;
}

.text-pretty {
  text-wrap: pretty;
}

.text-balance {
  text-wrap: balance;
}

/* Mobile Typography Optimization */
@media (max-width: 480px) {
  p,
  .page-lead,
  .service-details,
  .team-desc,
  .text-justify {
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
    text-wrap: pretty;
    overflow-wrap: break-word;
    text-align-last: left;
  }
}
