/* ==========================================================================
   Casa di Riposo Alfonso Rubilli – foglio di stile
   Plain CSS, no build step.
   Colors come from the original site, adjusted where needed so that every
   text and interface color passes WCAG 2.1 AA (see the table in CLAUDE.md).
   Rule: no inline styles anywhere – the Content-Security-Policy blocks them.
   ========================================================================== */

/* ---------- Fonts (self-hosted: visitors' browsers never contact Google) ----------
   Latin subset (covers Italian), downloaded from Fontsource 5.3.0 (fontsource.org,
   files "<font>-latin-<weight>-normal.woff2"). All under the SIL Open Font License 1.1:
   Atkinson Hyperlegible © Braille Institute of America; Questrial © The Questrial Project
   Authors; Parisienne © Brian J. Bonislawsky (Astigmatic). */
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-hyperlegible-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-hyperlegible-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Questrial";
  src: url("../fonts/questrial-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Parisienne";
  src: url("../fonts/parisienne-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ---------- Variables ---------- */
:root {
  /* Palette – contrast ratios measured against the background they are used on */
  --ochre: #8C6B3A;        /* header, footer, buttons – white text on it: 4.9:1 */
  --ochre-dark: #6F552E;   /* button hover */
  --green: #97B865;        /* original pistachio – decorative only (accent bar, icons) */
  --green-icon: #6E8F3D;   /* service icons */
  --green-light: #C2DB94;  /* active menu marker on ochre: 3.2:1 (UI state) */
  --logo: #D6E8B4;         /* script logo on ochre: 3.8:1 (large text) */
  --orange: #B84A00;       /* headings and links: 5.2:1 on white, 5.0:1 on #F9F9F9 */
  --orange-dark: #8A3600;  /* link hover */
  --orange-bright: #FF6600;/* original orange – decorative lines only */
  --text: #5C4626;         /* body text: 8.5:1 */
  --text-soft: #6E5530;    /* labels, meta text: 6.6:1 */
  --bg: #F9F9F9;
  --white: #FFFFFF;
  --band: #EEF3E4;
  --band-border: #DCE6CA;
  --border: #E4DCCD;
  --row-border: #EEE7DA;
  --focus: #2B2112;

  --font-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-head: "Questrial", "Century Gothic", "Avenir Next", system-ui, sans-serif;
  --font-logo: "Parisienne", "Brush Script MT", "Segoe Script", cursive;

  --radius: 16px;
  --container: 1160px;
  --gutter: 32px;
}

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

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

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.1875rem; /* 19px */
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

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

a {
  color: var(--orange);
  text-underline-offset: 3px;
}
a:hover {
  color: var(--orange-dark);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
/* Targets of the skip link get tabindex="-1": no outline on them */
[tabindex="-1"]:focus {
  outline: none;
}

h1,
h2,
h3 {
  font-family: var(--font-head);
  font-weight: 400;
  color: var(--orange);
  line-height: 1.2;
  margin: 0;
}
h1 {
  font-size: 2.875rem; /* 46px */
}
h2 {
  font-size: 2.25rem; /* 36px */
}

p {
  margin: 0;
}

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Lists styled without bullets keep role="list" in the HTML (Safari/VoiceOver) */
.plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Decorative orange line under headings, as on the original site */
.rule {
  height: 2px;
  width: 100%;
  max-width: 640px;
  background: linear-gradient(90deg, var(--orange-bright), rgba(255, 102, 0, 0) 75%);
}

/* Visible marker for content still missing in the draft (remove with the TODOs) */
.todo {
  background: #FFF3C4;
  color: #5C4626;
  padding: 0 4px;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 100;
  padding: 12px 20px;
  background: var(--white);
  color: var(--orange);
  font-weight: 700;
  border-radius: 8px;
}
.skip-link:focus {
  top: 16px;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--ochre);
  color: var(--white);
}
.site-header :focus-visible {
  outline-color: var(--white);
}
.header-inner {
  padding-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.logo {
  font-family: var(--font-logo);
  font-size: 2.875rem; /* 46px */
  line-height: 1.1;
  color: var(--logo);
  text-decoration: none;
  align-self: flex-start;
}
.logo:hover {
  color: var(--white);
}

.nav-list {
  font-family: var(--font-head);
  font-size: 1.0625rem; /* 17px */
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.nav-list a {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 0 14px;
  color: var(--white);
  text-decoration: none;
  border-bottom: 5px solid transparent;
}
.nav-list a:hover {
  border-bottom-color: rgba(255, 255, 255, 0.6);
}
.nav-list a[aria-current="page"] {
  border-bottom-color: var(--green-light);
}

/* Desktop menu */
.nav-desktop .nav-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0 6px;
}

/* Mobile menu: native <details>, no JavaScript.
   The flex layout sits on an inner span: some Safari versions
   do not allow <summary> itself to be a flex container. */
.nav-mobile {
  display: none;
}
.nav-mobile summary {
  display: block;
  list-style: none;
  cursor: pointer;
  border-radius: 12px;
}
.nav-mobile summary::-webkit-details-marker {
  display: none;
}
.summary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  margin-bottom: 14px;
  border: 2px solid var(--white);
  border-radius: 12px;
  font-weight: 700;
  font-size: 1.125rem;
}
.nav-mobile .icon-close {
  display: none;
}
.nav-mobile[open] .icon-close {
  display: inline;
}
.nav-mobile[open] .icon-open {
  display: none;
}
.nav-mobile .nav-list {
  padding-bottom: 14px;
}
.nav-mobile .nav-list a {
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  border-left: 5px solid transparent;
}
.nav-mobile .nav-list a[aria-current="page"] {
  border-bottom-color: rgba(255, 255, 255, 0.3);
  border-left-color: var(--green-light);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 28px;
  border-radius: 12px;
  background: var(--ochre);
  color: var(--white);
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
}
.btn:hover {
  background: var(--ochre-dark);
  color: var(--white);
}
.btn-outline {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border: 2px solid var(--ochre);
  border-radius: 10px;
  color: var(--text-soft);
  font-weight: 700;
  font-size: 1.0625rem;
  text-decoration: none;
  white-space: nowrap;
}
.btn-outline:hover {
  background: var(--ochre);
  color: var(--white);
}

/* ---------- Sections ---------- */
.section {
  padding-top: 64px;
  padding-bottom: 64px;
}
.section-stack {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.band-green {
  background: var(--band);
  border-top: 1px solid var(--band-border);
  border-bottom: 1px solid var(--band-border);
}
.band-white {
  background: var(--white);
  border-top: 1px solid var(--border);
}

/* ---------- Home: slideshow + mission ---------- */
.hero {
  display: flex;
  flex-wrap: wrap;
  gap: 48px;
  align-items: center;
  padding-top: 56px;
  padding-bottom: 56px;
}
.slideshow {
  flex: 1.2 1 480px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.slides {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 20px;
  overflow: hidden;
  background: var(--border);
}
/* Older browsers without aspect-ratio (e.g. iPads with iOS 14 or earlier): same 16:10 box */
@supports not (aspect-ratio: 1 / 1) {
  .slides::before {
    content: "";
    display: block;
    padding-top: 62.5%;
  }
}
/* The photos lie on top of each other; only those without `hidden` are shown */
.slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
.slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* The next photo fades in above the current one (slideshow.js: FADE = 1500) */
.slide.is-entering {
  z-index: 1;
  animation: slide-fade-in 1.5s ease-in-out;
}
@keyframes slide-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .slide.is-entering {
    animation: none;
  }
}
.slideshow-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}
.slideshow-dots[hidden] {
  display: none;
}
.slideshow-dot {
  width: 30px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Inactive = ring, active = filled: different shape, not only color */
.slideshow-dot::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--ochre);
  background: transparent;
  forced-color-adjust: none;
}
.slideshow-dot[aria-current="true"]::before {
  background: var(--ochre);
}
@media (forced-colors: active) {
  .slideshow-dot::before {
    border-color: CanvasText;
  }
  .slideshow-dot[aria-current="true"]::before {
    background: CanvasText;
  }
}

.mission {
  flex: 1 1 400px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.accent-bar {
  width: 64px;
  height: 5px;
  border-radius: 3px;
  background: var(--green);
}
.mission-lead {
  font-family: var(--font-head);
  font-size: 2rem; /* 32px */
  line-height: 1.3;
  color: var(--text);
}
.mission-text {
  font-size: 1.3125rem; /* 21px */
}
.mission .btn {
  align-self: flex-start;
}

/* ---------- Home: services ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}
.card {
  background: var(--white);
  border: 1px solid var(--band-border);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  gap: 16px;
  align-items: center;
}
.card svg {
  flex: 0 0 auto;
}

/* ---------- Home: history ---------- */
.storia {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.storia h2 {
  font-size: 2.5rem;
}
.storia p {
  max-width: 760px;
}
.storia .rule {
  max-width: 760px;
}

/* ---------- Contacts ---------- */
/* Two full-width cards: phone + email, then address + map.
   Inside each card the parts sit side by side and wrap on narrow screens. */
.contact-cards {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.contact-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 24px 64px;
  background: var(--white);
}
.contact-group {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
/* The map image is the link to Google Maps */
.contact-map {
  flex: 0 1 600px;
  min-width: 0;
  display: block;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.contact-map:hover {
  border-color: var(--orange);
}
.contact-map img {
  display: block;
  width: 100%;
  height: auto;
}
.label {
  font-family: var(--font-head);
  font-size: 0.9375rem; /* 15px */
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.contact-value {
  font-size: 1.3125rem;
  font-weight: 700;
}
.contact-email {
  font-size: 1.0625rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}
address {
  font-style: normal;
}

/* ---------- Inner pages ---------- */
.page {
  padding-top: 32px;
  padding-bottom: 72px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.page-title {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.breadcrumb {
  font-size: 1.0625rem;
}
.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.breadcrumb li + li::before {
  content: "›";
  margin-right: 6px;
  color: var(--text-soft);
}
.prose {
  max-width: 780px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-wrap: anywhere; /* long email addresses on narrow phones */
}
.prose h2 {
  font-size: 1.75rem;
  margin-top: 16px;
}

/* ---------- Document lists ---------- */
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  padding: 4px 20px;
}
.doc-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto; /* icon | title + size | button */
  gap: 8px 16px;
  align-items: center;
  padding: 14px 4px;
}
.doc-row + .doc-row {
  border-top: 1px solid var(--row-border);
}
.doc-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.35;
}
.doc-title {
  font-weight: 700;
}
.doc-meta {
  font-size: 1rem;
  color: var(--text-soft);
}

/* Trasparenza: one <details> per year */
.years {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.year {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  padding: 0 20px;
}
.year summary {
  display: block;
  list-style: none;
  cursor: pointer;
  border-radius: 8px;
}
.year summary::-webkit-details-marker {
  display: none;
}
.summary-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
}
.year-label {
  font-family: var(--font-head);
  font-size: 1.625rem;
  color: var(--orange);
}
.year-count {
  margin-left: auto;
  font-size: 1.0625rem;
  color: var(--text-soft);
}
.chevron {
  flex: 0 0 auto;
  color: var(--orange);
  transition: transform 0.15s ease;
}
.year[open] .chevron {
  transform: rotate(90deg);
}
.year .doc-list {
  border-top: 1px solid var(--row-border);
  margin-bottom: 8px;
}
@media (prefers-reduced-motion: reduce) {
  .chevron {
    transition: none;
  }
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--ochre);
  color: var(--white);
  font-size: 1.0625rem;
}
.site-footer :focus-visible {
  outline-color: var(--white);
}
.footer-inner {
  padding-top: 36px;
  padding-bottom: 36px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 40px;
  align-items: center;
  justify-content: space-between;
}
.footer-logo {
  font-family: var(--font-logo);
  font-size: 2rem;
  color: var(--logo);
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}
.footer-links a {
  color: var(--white);
}
.footer-links a:hover {
  color: var(--white);
  text-decoration-thickness: 3px;
}

/* ---------- 404 ---------- */
.notfound {
  padding-top: 72px;
  padding-bottom: 96px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: flex-start;
}

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  :root {
    --gutter: 18px;
  }
  body {
    font-size: 1.125rem; /* 18px */
  }
  h1 {
    font-size: 2.125rem;
  }
  h2,
  .storia h2 {
    font-size: 1.75rem;
  }
  .header-inner {
    padding-top: 14px;
    gap: 10px;
  }
  .logo {
    font-size: 2rem;
  }
  .nav-desktop {
    display: none;
  }
  .nav-mobile {
    display: block;
  }
  .hero {
    padding-top: 24px;
    padding-bottom: 32px;
    gap: 24px;
  }
  .slideshow,
  .mission {
    flex-basis: 100%;
  }
  .slideshow-dot {
    width: 28px;
  }
  .mission-lead {
    font-size: 1.5625rem;
  }
  .mission .btn {
    align-self: stretch;
  }
  .section {
    padding-top: 36px;
    padding-bottom: 36px;
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .panel,
  .year {
    padding-left: 14px;
    padding-right: 14px;
  }
  /* Phone: button goes under the title, aligned with it */
  .doc-row {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px 12px;
  }
  .doc-row > svg {
    align-self: start;
  }
  .doc-row .btn-outline {
    grid-column: 2;
    justify-self: start;
  }
  .footer-logo {
    font-size: 1.625rem;
  }
}

/* ---------- Print ---------- */
@media print {
  .site-header,
  .site-footer,
  .slideshow-dots,
  .skip-link {
    display: none;
  }
  body {
    background: #fff;
    color: #000;
  }
}
