/*
  K3 Ingenieria -- shared components
  Header/nav, footer, tick device, button base. Page-specific modules
  (hero, business-line rows, category tiles, forms) are NOT here -- they
  ship with each page.
*/

/* =========================================================
   Header / navigation
   ========================================================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40; /* above ordinary page content (z-index: auto everywhere
                  else in the project) but below the skip-link's z-index:
                  100 in layout.css, so a focused skip-link is never
                  hidden under the header. Sticky is still a valid
                  positioning context for the mobile nav-panel dropdown
                  below, same as the relative it replaces. */
  background: var(--paper); /* opaque -- scrolled content must not show
                                through while the header is pinned */
}

/* Compensates for the sticky header covering the top of the viewport:
   without this, jumping to #main (the skip-link's target, every page)
   or #lines-heading (Inicio's in-page link) lands the target's top
   edge directly under the header, hiding it. 120px covers the header's
   tallest real state (80px logo + 40px vertical padding at >=760px;
   104px at <760px) with a small safe margin rather than tracking the
   exact breakpoint-dependent height. */
#main {
  scroll-margin-top: 120px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: 1.25rem;
}

.logo-link { display: inline-flex; }
.logo-mark { display: block; height: 64px; width: auto; }
@media (min-width: 760px) {
  .logo-mark { height: 80px; }
}

.site-nav { display: flex; align-items: center; }

/* ---- Mobile nav toggle button (hidden >=760px, see breakpoint below) ---- */
.nav-toggle {
  display: none;
  align-items: center;
  gap: 0.6rem;
  background: none;
  border: none;
  padding: 0.5rem;
  margin: -0.5rem;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--navy);
}
.nav-toggle:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.nav-toggle-bars {
  position: relative;
  display: inline-block;
  width: 24px;
  height: 16px;
  flex-shrink: 0;
}
.nav-toggle-bars .bar {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--navy);
  border-radius: 1px;
  transition:
    transform var(--motion-panel) var(--ease-out),
    opacity var(--motion-panel) var(--ease-out),
    top var(--motion-panel) var(--ease-out);
}
.bar--top    { top: 0; }
.bar--mid    { top: 7px; }
.bar--bottom { top: 14px; }

/* three-bar -> X, driven by aria-expanded so state lives in one place */
.nav-toggle[aria-expanded="true"] .bar--top {
  top: 7px;
  transform: rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .bar--mid { opacity: 0; }
.nav-toggle[aria-expanded="true"] .bar--bottom {
  top: 7px;
  transform: rotate(-45deg);
}

/* ---- Nav panel ----
   >=760px: a plain static inline row (the plan's breakpoints only call
   for a toggle panel BELOW 760px; 760-1099 keeps the inline nav).
   <760px: becomes a collapsible dropdown controlled by js/nav.js. */
.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: row;
  gap: 2rem;
}
.nav-list a {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
}
.nav-list a[aria-current="page"] {
  text-decoration-thickness: 2px;
}

@media (max-width: 759.98px) {
  .nav-toggle { display: inline-flex; }

  .nav-panel {
    position: absolute;
    top: 100%;
    left: var(--container-pad);
    right: var(--container-pad);
    background: var(--surface);
    border: 1px solid var(--rule);
    border-top: none;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transition:
      max-height var(--motion-panel) var(--ease-out),
      opacity var(--motion-panel) var(--ease-out);
  }
  .nav-panel.is-open {
    max-height: 480px;
    opacity: 1;
    pointer-events: auto;
  }

  .nav-list {
    flex-direction: column;
    gap: 0;
    padding: 0.5rem var(--container-pad);
  }
  .nav-list li { border-bottom: 1px solid var(--rule-soft); }
  .nav-list li:last-child { border-bottom: none; }

  /* Real touch targets: the entire row is the clickable/tappable area,
     not just the inline text -- block display + explicit min-height,
     not an inline-block sized to its text content. */
  .nav-list a {
    display: block;
    width: 100%;
    min-height: 48px;
    padding: 14px 0;
    box-sizing: border-box;
  }
}

/* =========================================================
   Footer
   ========================================================= */

.site-footer {
  background: var(--paper);
  padding-block: 3rem clamp(1.5rem, 4vw, 3rem);
}

.footer-panel {
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius);
  padding: clamp(28px, 4vw, 56px) clamp(24px, 5vw, 56px);
}
.footer-panel a { color: #fff; }

/* Tick device -- one of only three approved sitewide placements (this,
   the page-head rule, and the consultoria process rail). Do not reuse
   elsewhere without checking DESIGN-PLAN.md Sec.3 first. Rendered as the
   first element inside the navy panel: an 8px band of repeating teal
   ticks at 24px intervals over a 1px teal-tint baseline. */
.tick-rule {
  height: 10px;
  margin-bottom: clamp(24px, 4vw, 40px);
  background-image:
    linear-gradient(var(--teal-tint) 0 0),
    repeating-linear-gradient(to right, var(--teal) 0 2px, transparent 2px 24px);
  background-position: bottom, top;
  background-repeat: no-repeat, repeat-x;
  background-size: 100% 1px, 100% 8px;
}
/* Same device, on paper/white ground instead of the navy footer panel --
   the teal-tint baseline is nearly invisible there, so it swaps to --rule.
   Used above each page's head (placement 2 of the 3 approved sitewide). */
.tick-rule--head {
  background-image:
    linear-gradient(var(--rule) 0 0),
    repeating-linear-gradient(to right, var(--teal) 0 2px, transparent 2px 24px);
}

/* =========================================================
   Page head
   Tick rule + eyebrow + H1 + standfirst -- opens every page except
   Inicio (which has its own hero instead). Shared here since five
   pages (Consultoria, Comercio, Nosotros, Contacto, Aviso) use it
   identically; page-specific CSS only adds what follows it.
   ========================================================= */
.page-head {
  padding-top: clamp(1.5rem, 4vw, 3rem);
  padding-bottom: clamp(2rem, 5vw, 3rem);
}
.page-head h1 { margin-bottom: 0.6em; }

.footer-grid {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr;
}
@media (min-width: 760px) {
  .footer-grid {
    grid-template-columns: 1.2fr 1fr 1fr;
    align-items: start;
  }
}

.footer-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.0625rem;
  margin: 0;
  max-width: 28ch;
}

.footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.footer-contact { margin: 0; }
.footer-contact .footer-email {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 600;
}
.footer-contact .footer-hours {
  margin: 0.6rem 0 0;
  color: var(--teal-tint);
  font-feature-settings: "tnum" 1;
}

.footer-meta {
  margin: 2rem 0 0;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--teal-tint);
  font-size: var(--fs-caption);
}

/* =========================================================
   Buttons
   Square corners, intrinsic width, min-height 48px, allowed to wrap.
   No pills, no fixed widths, no icons.
   ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  width: auto;
  min-height: 48px;
  padding: 0.75em 1.5em;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.2;
  text-decoration: none;
  white-space: normal; /* allow wrap to two lines for long Spanish labels */
  cursor: pointer;
  transition:
    background-color var(--motion-fast) var(--ease-out),
    color var(--motion-fast) var(--ease-out),
    border-color var(--motion-fast) var(--ease-out);
}
.btn:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.btn--primary { background: var(--navy); color: #fff; }
.btn--primary:hover,
.btn--primary:focus-visible { background: var(--navy-deep); }

.btn--secondary {
  background: transparent;
  color: var(--navy);
  border-color: var(--navy);
}
.btn--secondary:hover,
.btn--secondary:focus-visible {
  background: var(--navy);
  color: #fff;
}

/* =========================================================
   Image placeholder
   Flat navy-tinted box + bracketed label, standing in for real
   photography until it's shot/sourced (see DESIGN-PLAN.md Sec.4 for
   the imagery rules the eventual photos must follow). Shared across
   pages -- Inicio's hero/dos-lineas rows, Comercio's category tiles,
   Consultoria's 1:1 detail slots all use this rather than a bespoke
   box per page. Aspect ratios are limited to the plan's locked set.
   ========================================================= */
.image-placeholder {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  background-color: var(--rule-soft);
  background-image: repeating-linear-gradient(
    135deg,
    var(--rule) 0 1px,
    transparent 1px 14px
  );
  padding: 1rem;
  text-align: center;
}
.image-placeholder-label {
  font-family: var(--font-display);
  font-size: var(--fs-caption);
  line-height: var(--lh-caption);
  color: var(--text-secondary);
  max-width: 30ch;
}

.image-placeholder--3-4  { aspect-ratio: 3 / 4; }
.image-placeholder--4-3  { aspect-ratio: 4 / 3; }
.image-placeholder--1-1  { aspect-ratio: 1 / 1; }
.image-placeholder--21-9 { aspect-ratio: 21 / 9; }

@media (max-width: 759.98px) {
  /* 21:9 on a phone is a letterbox slit -- re-crop per Sec.3's
     responsive rules once real photography lands; the placeholder
     follows the same rule now so the layout doesn't lie about it. */
  .image-placeholder--21-9 { aspect-ratio: 3 / 2; }
}

/* =========================================================
   Motion moment 1: panel hover (realce de panel)
   Image scales to 1.02 inside a clipped frame; a teal rule beneath
   the panel's title grows from 32px to full width. 200ms, ease-out,
   pointer devices only (DESIGN-PLAN.md Sec.5). First used by home's
   "Las dos lineas" rows; reused as-is by Comercio's category tiles --
   built here, once, rather than per page.

   Structure expected: an element carrying .reveal-panel (the hover/
   focus root -- usually the row/tile's own <a>) containing a
   .reveal-media wrapper (clips the image/placeholder) and a
   .reveal-rule span (the growing underline, placed under the title).
   ========================================================= */
/* .reveal-panel is usually the row/tile's own <a> -- strip the
   default inline-link underline (it would draw under the whole
   block, image included) since the growing .reveal-rule is this
   panel's affordance and its focus signal instead. */
.reveal-panel {
  text-decoration: none;
  color: inherit;
}

.reveal-media { overflow: hidden; }
.reveal-media > * {
  transition: transform var(--motion-base) var(--ease-out);
}

.reveal-rule {
  display: block;
  width: 32px;
  height: 2px;
  margin-top: 0.5em;
  background: var(--teal);
  transition: width var(--motion-base) var(--ease-out);
}

@media (hover: hover) {
  .reveal-panel:hover .reveal-media > *,
  .reveal-panel:focus-visible .reveal-media > * {
    transform: scale(1.02);
  }
  .reveal-panel:hover .reveal-rule,
  .reveal-panel:focus-visible .reveal-rule {
    width: 100%;
  }
}

/* =========================================================
   Definition-list pattern ("Como trabajamos" / "Mision y Vision" /
   "Como operamos")
   Label rail left, prose right, hairline between rows. First used on
   Inicio, reused as-is on Nosotros -- twice, for both "Mision y Vision"
   and "Como operamos dia a dia" (item count varies, 2 vs 3; the grid
   itself doesn't assume a fixed count). The dt/dd pairs are each
   wrapped in a <div> (valid dl grouping per HTML5.1) so display:contents
   can hand them to the grid as direct children without an extra level.
   ========================================================= */
.how-we-work {
  padding-block: clamp(2rem, 5vw, 4rem);
  border-top: 1px solid var(--rule-soft);
}
.how-we-work-heading { margin-bottom: clamp(1.5rem, 4vw, 2.5rem); }

.how-we-work-list {
  display: grid;
  grid-template-columns: minmax(160px, 3fr) minmax(0, 9fr);
  gap: 0 var(--grid-gap);
  margin: 0;
}
.how-we-work-list > div { display: contents; }

.how-we-work-list dt {
  grid-column: 1;
  padding-block: 1.25rem;
  border-top: 1px solid var(--rule-soft);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--navy);
}
.how-we-work-list dd {
  grid-column: 2;
  margin: 0;
  padding-block: 1.25rem;
  border-top: 1px solid var(--rule-soft);
  max-width: 60ch;
}

@media (max-width: 1099.98px) {
  .how-we-work-list { grid-template-columns: 1fr; }
  .how-we-work-list dt,
  .how-we-work-list dd { grid-column: 1; }
  .how-we-work-list dd { border-top: none; padding-top: 0; }
}

/* =========================================================
   Cross-link block
   A rule-and-label block at a page's foot -- teal 2px top rule, one
   short line of text, one link. Not a button, not a card. First built
   for Consultoria's link to Comercio, reused as-is (moved here from
   consultoria.css) once Comercio started linking to Contacto with the
   exact same treatment. The first <p> inside .cross-link can be an
   .eyebrow label (Consultoria's usage) or plain text (Comercio's) --
   `p:first-child` doesn't care which, it only needs a first paragraph
   to put space under.

   Padding-block assumes this is the page's last section before the
   footer, since both current uses are -- if a future page ever wants
   this mid-page, override padding-bottom for that page specifically
   rather than changing the shared default. */
.cross-link-section {
  padding-block: clamp(2rem, 5vw, 3rem) clamp(3rem, 6vw, 4rem);
}
.cross-link {
  border-top: 2px solid var(--teal);
  padding-top: 1.25rem;
}
.cross-link p:first-child { margin-bottom: 0.5em; }
.cross-link-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.0625rem;
  margin: 0;
}
