/* ==========================================================================
   GEOPORTA — custom layer on top of Pico CSS (classless · sand)
   Load order: pico.classless.sand.min.css → style.css

   Two sections:
     1. BASE   — theme tokens (Pico variable overrides + local design tokens),
                 project-wide resets and element defaults
     2. CUSTOM — per-component styling. One class per component; everything
                 inside a component is reached with CSS nesting on semantic
                 elements, so the markup stays classless.

   Units: sizes are relative (rem / em / % / vw-vh clamps) so they ride
   Pico's responsive root-font scaling. Only hairline borders stay at 1px.

   Theming: colours are expressed as RGB-triplet tokens (--ink-rgb, etc.)
   and consumed with rgba(var(--token), a). The light values live in the
   light :root block; a prefers-color-scheme:dark block re-points only the
   atomic tokens, so every derived colour (borders, muted text, washes,
   Pico vars) flips automatically. Shadows use their own --shadow-rgb so
   they stay dark in both themes instead of inverting.
   ========================================================================== */


/* ============================ 1. BASE ============================ */

/* Light theme — scoped to Pico's own light-scheme selector so it wins
   by source order. Applies by default and whenever the user prefers light. */
:root:not([data-theme=dark]) {
  color-scheme: light;

  /* -- atomic colour tokens -- */
  --ink: #23211C;               --ink-rgb: 35, 33, 28;      /* text / borders */
  --green: #4A5D50;             --green-rgb: 74, 93, 80;    /* accent */
  --cream: #F4F1EB;             --cream-rgb: 244, 241, 235; /* page bg */
  --cream-deep: #ECE6DA;                                    /* opinie band */
  --cream-hi: #EFEADF;                                      /* hero highlight */
  --paper: #FCFBF7;             --paper-rgb: 252, 251, 247; /* solid cards */
  --surface-rgb: 251, 250, 246;                             /* glass cards */
  --hover-rgb: 255, 255, 255;                               /* card hover wash */
  --shadow-rgb: 35, 33, 28;                                 /* elevation */

  /* -- derived tokens (auto-flip via the atoms above) -- */
  --line: rgba(var(--ink-rgb), 0.12);
  --font-serif: 'Spectral', serif;
  --wash-green: rgba(var(--green-rgb), 0.07);
  --wash-clay:  rgba(140, 107, 69, 0.07);
  --wash-slate: rgba(62, 110, 134, 0.06);

  /* -- Pico variable overrides -- */
  --pico-font-family: "Manrope", system-ui, sans-serif;
  --pico-border-radius: 0.5rem;
  --pico-background-color: var(--cream);
  --pico-color: var(--ink);
  --pico-muted-color: #6f6a61;
  --pico-muted-border-color: var(--line);
  --pico-h1-color: var(--ink);
  --pico-h2-color: var(--ink);
  --pico-h3-color: var(--ink);
  --pico-h4-color: var(--ink);
  --pico-h5-color: var(--ink);
  --pico-h6-color: var(--ink);
  --pico-primary: var(--green);
  --pico-primary-hover: var(--ink);
  --pico-primary-focus: rgba(var(--green-rgb), 0.35);
  --pico-primary-underline: transparent;
  --pico-text-selection-color: rgba(var(--green-rgb), 0.28);
  --pico-card-background-color: var(--paper);
  --pico-card-sectioning-background-color: var(--paper);
  --pico-card-border-color: var(--line);
  --pico-card-box-shadow: 0 1.25rem 3.125rem -2.125rem rgba(var(--shadow-rgb), 0.3);
  --pico-blockquote-border-color: transparent;
}

/* Dark theme — re-point only the atomic tokens. Everything derived above
   (--line, washes, --pico-*) recomputes from these. Applies on a dark
   system preference unless the user has forced [data-theme=light]. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    color-scheme: dark;

    --ink: #E7E1D4;             --ink-rgb: 231, 225, 212;   /* warm off-white */
    --green: #90A98F;           --green-rgb: 144, 169, 143; /* lifted sage */
    --cream: #171511;           --cream-rgb: 23, 21, 17;    /* deep warm bg */
    --cream-deep: #1E1B16;                                  /* opinie band */
    --cream-hi: #221E18;                                    /* hero highlight */
    --paper: #232019;           --paper-rgb: 35, 32, 25;    /* solid cards */
    --surface-rgb: 40, 36, 28;                              /* glass cards */
    --hover-rgb: 62, 57, 45;                                /* card hover wash */
    --shadow-rgb: 0, 0, 0;                                  /* shadows stay dark */
    --wash-clay:  rgba(140, 107, 69, 0.10);
    --wash-slate: rgba(62, 110, 134, 0.10);

    --pico-muted-color: #a49d8c;
  }

  /* keep the embedded OSM map from glaring against the dark page */
  .services .map iframe {
    filter: grayscale(0.4) contrast(0.9) brightness(0.9) invert(0.92) hue-rotate(180deg);
  }
}

/* -- resets & project-wide element settings -- */
* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Neutralise Pico's container on <main> so sections can span full width. */
body > main {
  max-width: none;
  margin: 0;
  padding: 0;
}

/* top bar in landscape, bottom bar in portrait */
[id] { scroll-margin-top: 2rem; }
@media (orientation: portrait) {
  [id] { scroll-margin-top: unset; scroll-margin-bottom: 4.75rem; }
  body { padding-bottom: 2rem; }   /* room for the bottom nav bar */
}

/* display typography */
h1, h2, h3, h4, h5, h6, blockquote, .brand {
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.01em;
}
h1 { font-weight: 400; }

/* links never underline in this design */
a { text-decoration: none; }

/* shared uppercase label */
.eyebrow {
  margin: 0;
  font-family: var(--pico-font-family);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--green);
}

/* wordmark, used in the nav and the footer */
.brand {
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  color: var(--ink);
}

@keyframes waveDrift {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}


/* ============================ 2. CUSTOM ============================ */

/* ---- navigation -------------------------------------------------------- */
/* Default (landscape): a fixed top bar with content-sized links.
   Portrait: a bottom-anchored bar of buttons that size to their text. */
body > nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  padding: 0.875rem clamp(1.25rem, 5vw, 4rem);
  background: rgba(var(--cream-rgb), 0.72);
  backdrop-filter: blur(0.75rem);
  -webkit-backdrop-filter: blur(0.75rem);
  border-bottom: 1px solid rgba(var(--ink-rgb), 0.08);

  & ul { width: auto; margin: 0; padding: 0; gap: clamp(1rem, 2.4vw, 1.875rem); }
  & li { flex: 0 0 auto; padding: 0; }
  & li::before { content: none; }

  & li a {
    display: inline-block;
    padding: 0;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink);
    white-space: nowrap;
    transition: color 0.2s ease, background 0.2s ease;
  }
  & li a:hover, & li a:active { color: var(--green); }
}

@media (orientation: portrait) {
  body > nav {
    inset: auto 0 0 0;            /* pinned to the bottom */
    padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
    background: rgba(var(--cream-rgb), 0.85);
    backdrop-filter: blur(1rem);
    -webkit-backdrop-filter: blur(1rem);
    border-bottom: none;
    border-top: 1px solid rgba(var(--ink-rgb), 0.10);
    box-shadow: 0 -0.625rem 1.875rem -1.25rem rgba(var(--shadow-rgb), 0.55);

    & .brand { display: none; }

    & ul { width: 100%; justify-content: space-around; gap: 0.375rem; }
    & li { flex: 0 1 auto; }       /* size to contents — no forced wrap */

    & li a {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0.625rem 0.75rem;
      border-radius: 0.75rem;
      letter-spacing: 0.06em;
    }
    & li a:hover, & li a:active { background: rgba(var(--green-rgb), 0.12); color: var(--green); }
  }
}

/* ---- hero / kontakt ---------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  min-height: 100svh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(5.625rem, 14vh, 8.75rem) clamp(1.25rem, 5vw, 4rem) clamp(3rem, 8vh, 5rem);
  scroll-snap-align: start;

  /* base gradient (::before) + soft focal veil (::after) */
  &::before, &::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
  &::before { background: radial-gradient(120% 90% at 78% 12%, var(--cream-hi) 0%, var(--cream) 42%, var(--cream-deep) 100%); }
  &::after  { background: radial-gradient(80% 60% at 50% 55%, rgba(var(--cream-rgb), 0.35) 0%, rgba(var(--cream-rgb), 0) 60%); }

  /* animated strata: pre-rendered static SVG, drifted with CSS (no JS needed);
     the script only re-derives each band's parameters when JS is available. */
  & > #contour {
    position: absolute;
    inset: 0;
    overflow: hidden;

    & .wave {
      position: absolute;
      left: 0;
      top: 0;
      width: 200%;
      height: 100%;
      animation: waveDrift var(--dur, 60s) linear infinite var(--dir, normal);
    }
    & .wave__line { fill: none; stroke: rgba(255, 255, 255, 0.22); stroke-width: 1.2; }
  }

  /* contact card */
  & > article {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 35rem;
    margin: 0;
    padding: clamp(1.875rem, 5vw, 3.25rem);
    background: rgba(var(--paper-rgb), 0.94);
    backdrop-filter: blur(0.25rem);
    border: 1px solid var(--line);
    border-radius: 0.3125rem;
    box-shadow: 0 1.875rem 4.375rem -1.875rem rgba(var(--shadow-rgb), 0.35), 0 0.125rem 0.375rem rgba(var(--shadow-rgb), 0.06);

    & h1 { margin: 0.35rem 0 0; font-size: clamp(2.875rem, 8.5vw, 5.125rem); line-height: 0.98; }

    & > p:last-of-type {
      margin: 0.6rem 0 0;
      font-family: var(--font-serif);
      font-style: italic;
      font-weight: 300;
      font-size: clamp(1.0625rem, 2.4vw, 1.3125rem);
      line-height: 1.4;
      color: rgba(var(--ink-rgb), 0.66);
      max-width: 40ch;
    }

    & hr { margin: 1.75rem 0; height: 1px; border: none; background: var(--line); }

    & dl {
      display: grid;
      grid-template-columns: 5.5rem 1fr;
      row-gap: 1.125rem;
      column-gap: 1rem;
      margin: 0;
      font-size: 0.90625rem;
      line-height: 1.5;
    }
    & dt {
      margin: 0;
      padding-top: 0.125rem;
      font-size: 0.6875rem;
      font-weight: 700;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      color: rgba(var(--ink-rgb), 0.45);
    }
    & dd { margin: 0; }
    & dd small { color: rgba(var(--ink-rgb), 0.6); }
  }

  /* scroll cue */
  & > small {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(var(--ink-rgb), 0.4);
  }
}

/* ---- usługi (services + map) ------------------------------------------- */
.services {
  position: relative;
  min-height: 100svh;
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(5.625rem, 12vh, 7.5rem) clamp(1.25rem, 5vw, 4rem);
  scroll-snap-align: start;
  background: var(--cream);

  &::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
      radial-gradient(46% 40% at 10% 6%,   var(--wash-green), transparent 70%),
      radial-gradient(48% 46% at 94% 26%,  var(--wash-clay),  transparent 70%),
      radial-gradient(60% 50% at 72% 104%, var(--wash-slate), transparent 70%);
  }

  /* centre every direct block to the content width */
  & > * { position: relative; z-index: 1; width: 100%; max-width: 77.5rem; margin-inline: auto; }

  /* section intro: eyebrow + title on the left, tagline on the right */
  & > header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: clamp(1.75rem, 4vh, 2.75rem);

    & h2 { margin: 0.3rem 0 0; font-size: clamp(2.125rem, 5.5vw, 3.625rem); line-height: 1; }
    & > p:last-child {
      margin: 0;
      max-width: 34ch;
      font-family: var(--font-serif);
      font-style: italic;
      font-weight: 300;
      font-size: clamp(0.9375rem, 1.8vw, 1.1875rem);
      color: rgba(var(--ink-rgb), 0.6);
    }
  }

  /* the section's only <div> is the card grid */
  & > div {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14.375rem, 1fr));
    gap: clamp(0.75rem, 1.4vw, 1rem);
  }

  /* service card — colour comes from an inline --accent per card */
  & article {
    --pico-card-box-shadow: 0 0.0625rem 0.125rem rgba(var(--shadow-rgb), 0.04);
    position: relative;
    overflow: hidden;
    margin: 0;
    min-height: 12.625rem;
    padding: clamp(1.375rem, 2.4vw, 1.75rem);
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    background: rgba(var(--surface-rgb), 0.5);
    backdrop-filter: blur(0.375rem);
    -webkit-backdrop-filter: blur(0.375rem);
    border: 1px solid rgba(var(--ink-rgb), 0.10);
    border-radius: 0.5rem;
    transition: background 0.25s ease;

    &:hover { background: rgba(var(--hover-rgb), 0.64); }

    /* large faded background glyph (the card's direct-child svg) */
    & > svg {
      position: absolute;
      right: -1rem;
      bottom: -1.25rem;
      width: 7.375rem;
      height: 7.375rem;
      pointer-events: none;
      color: var(--accent);
      opacity: 0.12;
    }

    /* icon chip + index row */
    & > p:first-of-type {
      position: relative;
      z-index: 1;
      display: flex;
      align-items: center;
      gap: 0.625rem;
      margin: 0;
      font-family: var(--font-serif);
      font-size: 0.9375rem;
      color: var(--green);
    }
    & span {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 2.125rem;
      height: 2.125rem;
      border-radius: 0.5625rem;
      background: color-mix(in srgb, var(--accent) 12%, transparent);
      color: var(--accent);
    }
    & span svg { width: 1.1875rem; height: 1.1875rem; }

    & h3 {
      position: relative;
      z-index: 1;
      margin: 0.25rem 0 0;
      font-size: clamp(1.1875rem, 2vw, 1.4375rem);
      line-height: 1.15;
    }
    & > p:last-of-type {
      position: relative;
      z-index: 1;
      margin: 0;
      font-size: 0.84375rem;
      line-height: 1.5;
      color: rgba(var(--ink-rgb), 0.58);
      white-space: pre-line;
    }
  }

  /* obszar działania (map) */
  & > .map {
    margin: clamp(1.75rem, 4vh, 2.75rem) auto 0;

    & figcaption {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      gap: 1rem;
      flex-wrap: wrap;
      margin-bottom: 0.875rem;
      padding: 0;
      text-align: left;
      color: var(--ink);

      & h3 { margin: 0; font-size: clamp(1.25rem, 2.4vw, 1.625rem); }
      & a { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }
    }

    & iframe {
      display: block;
      width: 100%;
      height: clamp(17.5rem, 42vh, 27.5rem);
      border: 1px solid var(--line);
      border-radius: 0.3125rem;
      box-shadow: 0 1.25rem 3.125rem -1.875rem rgba(var(--shadow-rgb), 0.3);
      filter: grayscale(0.35) contrast(0.96);
    }

    & > p { margin: 0.75rem 0 0; font-size: 0.78125rem; color: rgba(var(--ink-rgb), 0.5); }
  }
}

/* ---- opinie (testimonials) + partnerzy + footer ------------------------ */
.testimonials {
  position: relative;
  min-height: 100svh;
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(5.625rem, 12vh, 7.5rem) clamp(1.25rem, 5vw, 4rem);
  scroll-snap-align: start;
  background: var(--cream-deep);

  & > * { width: 100%; max-width: 73.75rem; margin-inline: auto; }

  & > header {
    text-align: center;
    margin-bottom: clamp(2.125rem, 5vh, 3.5rem);
    & h2 { margin: 0.3rem 0 0; font-size: clamp(2.125rem, 5.5vw, 3.625rem); line-height: 1; }
  }

  /* quote grid (the section's only direct <div>) */
  & > div {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(17.5rem, 1fr));
    gap: clamp(1rem, 2vw, 1.75rem);
  }

  & figure {
    margin: 0;
    padding: clamp(1.625rem, 3vw, 2.375rem);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 0.3125rem;
    box-shadow: 0 1.25rem 3.125rem -2.125rem rgba(var(--shadow-rgb), 0.3);

    & blockquote {
      margin: 0;
      padding: 0;
      border: none;
      font-weight: 300;
      font-size: clamp(1.0625rem, 1.9vw, 1.25rem);
      line-height: 1.5;
      color: var(--ink);

      &::before {
        content: "\201C";
        display: block;
        height: 1.5rem;
        font-size: 3.25rem;
        line-height: 0.4;
        color: rgba(var(--green-rgb), 0.35);
      }
    }

    & figcaption {
      margin-top: auto;
      padding: 0.5rem 0 0;
      border-top: 1px solid rgba(var(--ink-rgb), 0.1);
      text-align: left;
      color: var(--ink);

      & strong { font-weight: 600; font-size: 0.875rem; }
      & small { display: block; margin-top: 0.125rem; font-size: 0.8125rem; color: rgba(var(--ink-rgb), 0.55); }
    }
  }

  /* zaufani partnerzy */
  & .partners {
    margin-top: clamp(3rem, 7vh, 5.25rem);
    margin-bottom: 0;

    & > header {
      text-align: center;
      margin-bottom: clamp(1.375rem, 4vh, 2.375rem);
      & h3 { margin: 0.3rem 0 0; font-size: clamp(1.625rem, 4vw, 2.625rem); line-height: 1.05; }
    }

    & > div {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(13.125rem, 1fr));
      gap: clamp(0.75rem, 1.4vw, 1.125rem);
    }

    /* partner tile — gradient comes from inline --from / --to. These tiles keep
       their vivid gradients and white text in both themes. */
    & a {
      position: relative;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      min-height: 9.875rem;
      padding: 1.125rem;
      border-radius: 0.5625rem;
      color: #fff;
      background: linear-gradient(150deg, var(--from), var(--to));
      box-shadow: 0 0.875rem 2.125rem -1.375rem rgba(var(--shadow-rgb), 0.6);
      transition: transform 0.25s ease, box-shadow 0.25s ease;

      &:hover {
        transform: translateY(-0.3125rem);
        box-shadow: 0 1.375rem 2.875rem -1.375rem rgba(var(--shadow-rgb), 0.7);
        color: #fff;
      }

      /* faded corner glyph (z0) < scrim (z1) < text (z2) */
      & > svg {
        position: absolute;
        right: -1.125rem;
        bottom: -1.5rem;
        z-index: 0;
        width: 8.25rem;
        height: 8.25rem;
        color: rgba(255, 255, 255, 0.16);
      }
      &::after {
        content: "";
        position: absolute;
        inset: 0;
        z-index: 1;
        background: linear-gradient(to top, rgba(24, 22, 18, 0.52), rgba(24, 22, 18, 0.04) 62%);
      }
      & :is(small, strong) { position: relative; z-index: 2; }

      & small:first-of-type { font-size: 0.625rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; opacity: 0.85; }
      & strong { display: block; margin: 0.3125rem 0 0.375rem; font-family: var(--font-serif); font-weight: 500; font-size: clamp(1.1875rem, 2vw, 1.4375rem); line-height: 1.1; }
      & small:last-of-type { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em; opacity: 0.9; }
    }
  }

  & > footer {
    margin-top: clamp(2.75rem, 7vh, 4.5rem);
    padding: 1.5rem 0 0;
    border-top: 1px solid rgba(var(--ink-rgb), 0.14);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.75rem;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78125rem;
    color: rgba(var(--ink-rgb), 0.55);

    & .brand { font-size: 1.125rem; }
  }
}
