/* ==========================================================================
   CADGISTools — main stylesheet
   Sections: 1 Tokens · 2 Base · 3 Layout · 4 Header/Nav · 5 Hero
             6 Sections & Cards · 7 Page content · 8 Ad slots · 9 Footer · 10 Utilities
   ========================================================================== */

/* 1. Design tokens — change colours/spacing here */
:root {
  --c-bg: #f6f8fa;
  --c-surface: #fff;
  --c-text: #1c2530;
  --c-muted: #5a6776;
  --c-border: #dde3ea;
  --c-primary: #0b5ea8;
  --c-primary-dark: #084a85;
  --c-accent: #0f8a6a;
  --c-dark: #13202e;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(16, 32, 48, .08);
  --wrap: 1140px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

/* 2. Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.65 var(--font);
  color: var(--c-text);
  background: var(--c-bg);
}
[hidden] { display: none !important; }
img, svg { max-width: 100%; height: auto; }
a { color: var(--c-primary); }
a:hover { color: var(--c-primary-dark); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; color: var(--c-dark); }
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); }
h3 { font-size: 1.125rem; }
p { margin: 0 0 1em; }
code { font-family: var(--mono); font-size: .9em; }
:focus-visible { outline: 3px solid var(--c-accent); outline-offset: 2px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--c-dark); color: #fff; padding: .5rem 1rem; z-index: 10; }
.skip-link:focus { left: 0; }

/* 3. Layout */
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1rem; }
main { display: block; min-height: 60vh; }
.section { padding: 3rem 0; }
.section-alt { background: var(--c-surface); border-block: 1px solid var(--c-border); }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .5rem 1rem; margin-bottom: 1.25rem; }
.section-head h2 { margin: 0; }
.section-head p { margin: 0; color: var(--c-muted); flex-basis: 100%; }

/* 4. Header / navigation */
.site-header { background: var(--c-dark); color: #fff; position: sticky; top: 0; z-index: 5; }
.nav-bar { display: flex; align-items: center; justify-content: space-between; min-height: 60px; }
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.brand:hover { color: #fff; }
.brand span { color: #6cc3f5; }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: .25rem; }
.nav a { display: block; padding: .5rem .75rem; color: #d5dee8; text-decoration: none; border-radius: var(--radius); font-size: .95rem; }
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.nav a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, .14); }
.nav-toggle { display: none; background: none; border: 1px solid rgba(255, 255, 255, .3); color: #fff; border-radius: var(--radius); padding: .35rem .6rem; font-size: 1.25rem; line-height: 1; cursor: pointer; }

@media (max-width: 800px) {
  .nav-toggle { display: block; }
  .nav { display: none; position: absolute; top: 60px; left: 0; right: 0; background: var(--c-dark); border-top: 1px solid rgba(255, 255, 255, .1); }
  .nav.open { display: block; }
  .nav ul { flex-direction: column; padding: .5rem 1rem 1rem; }
}

/* 5. Hero / page header */
.hero { background: var(--c-dark); color: #d5dee8; padding: 3.5rem 0 3rem; }
.hero h1 { color: #fff; max-width: 20ch; }
.hero p { font-size: 1.125rem; max-width: 60ch; }
.hero .btn-row { margin-top: 1.5rem; }
.page-head { background: var(--c-surface); border-bottom: 1px solid var(--c-border); padding: 2.25rem 0 1.75rem; }
.page-head p { color: var(--c-muted); max-width: 65ch; margin: 0; }
.breadcrumb { font-size: .875rem; color: var(--c-muted); margin-bottom: .5rem; }
.breadcrumb ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; }
.breadcrumb li + li::before { content: "/"; padding: 0 .4rem; }

/* Buttons */
.btn-row { display: flex; flex-wrap: wrap; gap: .75rem; }
.btn { display: inline-block; padding: .65rem 1.2rem; border-radius: var(--radius); background: var(--c-primary); color: #fff; text-decoration: none; font-weight: 600; border: 1px solid var(--c-primary); cursor: pointer; font: inherit; }
.btn:hover { background: var(--c-primary-dark); color: #fff; }
.btn-outline { background: transparent; color: inherit; border-color: currentColor; }
.btn-outline:hover { background: rgba(255, 255, 255, .08); color: inherit; }

/* 6. Cards */
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.card h3 { margin-bottom: .35rem; }
.card h3 a { color: var(--c-dark); text-decoration: none; }
.card h3 a:hover { color: var(--c-primary); }
.card p { color: var(--c-muted); font-size: .95rem; flex-grow: 1; }
.card-icon { width: 40px; height: 40px; border-radius: var(--radius); background: #e6f0f9; color: var(--c-primary); display: grid; place-items: center; font-weight: 700; margin-bottom: .75rem; font-family: var(--mono); }
.tag { display: inline-block; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: .15rem .5rem; border-radius: 4px; background: #eef2f6; color: var(--c-muted); align-self: flex-start; }
.tag-free { background: #e3f4ee; color: #0b6b52; }
.tag-paid { background: #fdf1dc; color: #8a5a00; }
.card-cat { background: var(--c-dark); color: #d5dee8; border: 0; }
.card-cat h3, .card-cat h3 a { color: #fff; }
.card-cat p { color: #b3c1cf; }

/* Funnel steps on home page */
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); counter-reset: s; }
.steps li { counter-increment: s; padding: 1rem 1rem 1rem 3.25rem; position: relative; background: var(--c-bg); border-radius: var(--radius); border: 1px solid var(--c-border); }
.steps li::before { content: counter(s); position: absolute; left: 1rem; top: 1rem; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--c-primary); color: #fff; display: grid; place-items: center; font-size: .85rem; font-weight: 700; }

/* 7. Page content (articles, tool pages, about) */
.content-layout { display: grid; gap: 2rem; grid-template-columns: minmax(0, 1fr) 300px; padding: 2.5rem 0; }
@media (max-width: 900px) { .content-layout { grid-template-columns: minmax(0, 1fr); } }
.prose { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: clamp(1.25rem, 3vw, 2rem); }
.prose h2 { margin-top: 1.75rem; }
.prose h2:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.25rem; }
.sidebar > * + * { margin-top: 1rem; }
.sidebar .card h2 { font-size: 1rem; }
.sidebar ul { margin: 0; padding-left: 1.1rem; }

/* Tool widget box */
.tool-box { background: var(--c-bg); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 1.25rem; margin: 1rem 0 1.5rem; }
.form-row { display: grid; gap: .35rem; margin-bottom: 1rem; }
label { font-weight: 600; font-size: .95rem; }
input, select, textarea { font: inherit; padding: .6rem .75rem; border: 1px solid var(--c-border); border-radius: var(--radius); background: #fff; color: var(--c-text); width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--c-primary); outline: none; box-shadow: 0 0 0 3px rgba(11, 94, 168, .15); }

/* Video: fixed 16:9 box so nothing shifts when a video is added */
.video { position: relative; aspect-ratio: 16 / 9; max-width: 100%; background: #000; border-radius: var(--radius); overflow: hidden; margin: 1rem 0 1.5rem; display: grid; place-items: center; color: #b3c1cf; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.notice { border-left: 4px solid var(--c-primary); background: #eef5fb; padding: .75rem 1rem; border-radius: 0 var(--radius) var(--radius) 0; }

/* 8. Ad slots — reserved space prevents layout shift when ads are enabled.
   Add class "ad-slot" to a container ONLY when real ad code is placed inside it. */
.ad-slot { display: block; min-height: 280px; margin: 1.5rem 0; text-align: center; }
.ad-slot-banner { min-height: 100px; }

/* 9. Footer */
.site-footer { background: var(--c-dark); color: #b3c1cf; padding: 2.5rem 0 1.5rem; margin-top: 3rem; font-size: .95rem; }
.footer-grid { display: grid; gap: 1.5rem; grid-template-columns: 2fr repeat(2, 1fr); }
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > :first-child { grid-column: 1 / -1; } }
.site-footer h2 { color: #fff; font-size: 1rem; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: .35rem; }
.site-footer a { color: #d5dee8; text-decoration: none; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, .1); margin-top: 2rem; padding-top: 1rem; font-size: .875rem; }

/* 10. Utilities */
.muted { color: var(--c-muted); }
.center { text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 11. Motion — opacity/transform only; everything is disabled for prefers-reduced-motion.
   .reveal is added by main.js only to elements below the fold, so content is never hidden without JS. */
.hero { position: relative; overflow: hidden; }
.hero > .wrap { position: relative; z-index: 1; }
@media (prefers-reduced-motion: no-preference) {
  .hero > .wrap > *, .page-head .wrap > *, .profile-text > * { animation: rise .6s cubic-bezier(.2, .7, .2, 1) both; }
  .hero > .wrap > :nth-child(2), .page-head .wrap > :nth-child(2), .profile-text > :nth-child(2) { animation-delay: .08s; }
  .hero > .wrap > :nth-child(3), .page-head .wrap > :nth-child(3), .profile-text > :nth-child(3) { animation-delay: .16s; }
  .hero > .wrap > :nth-child(4), .profile-text > :nth-child(4) { animation-delay: .24s; }
  @keyframes rise { from { opacity: 0; transform: translateY(16px); } }

  .reveal { opacity: 0; transform: translateY(20px); }
  .reveal.in { opacity: 1; transform: none; transition: opacity .6s cubic-bezier(.2, .7, .2, 1) var(--d, 0s), transform .6s cubic-bezier(.2, .7, .2, 1) var(--d, 0s); }

  /* Home intro: portrait rises inside the hero on a survey-grid glow with CAD selection corners.
     Created by intro.js, removed after ~2.4 s. Absolute inside .hero, so it scrolls away and never covers the page. */
  .intro { --b: rgba(108, 195, 245, .75); position: absolute; inset: 0; pointer-events: none; transition: opacity .25s; }
  .intro.out { opacity: 0; }
  .intro .wrap { position: relative; height: 100%; }
  .intro-stage { position: absolute; right: 1rem; top: 1.25rem; bottom: 0; aspect-ratio: 1122 / 1402; max-width: calc(100% - 2rem); }
  .intro-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: bottom; --peak: 1; animation: intro-img 2.4s cubic-bezier(.2, .7, .2, 1) both; }
  .intro-glow { position: absolute; inset: 6% -22% -4%; background: radial-gradient(closest-side, rgba(108, 195, 245, .30), rgba(108, 195, 245, .07) 62%, transparent), repeating-linear-gradient(0deg, rgba(108, 195, 245, .12) 0 1px, transparent 1px 28px), repeating-linear-gradient(90deg, rgba(108, 195, 245, .12) 0 1px, transparent 1px 28px); -webkit-mask: radial-gradient(closest-side, #000 50%, transparent); mask: radial-gradient(closest-side, #000 50%, transparent); animation: intro-fade 2.4s ease both; }
  .intro-frame { position: absolute; inset: 3% -7% 0; background: linear-gradient(var(--b), var(--b)) 0 0 / 24px 2px, linear-gradient(var(--b), var(--b)) 0 0 / 2px 24px, linear-gradient(var(--b), var(--b)) 100% 0 / 24px 2px, linear-gradient(var(--b), var(--b)) 100% 0 / 2px 24px, linear-gradient(var(--b), var(--b)) 0 100% / 24px 2px, linear-gradient(var(--b), var(--b)) 0 100% / 2px 24px, linear-gradient(var(--b), var(--b)) 100% 100% / 24px 2px, linear-gradient(var(--b), var(--b)) 100% 100% / 2px 24px; background-repeat: no-repeat; animation: intro-frame 2.4s cubic-bezier(.2, .7, .2, 1) both; }
  @keyframes intro-fade { 0% { opacity: 0; } 25% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
  @keyframes intro-frame { 0% { opacity: 0; transform: scale(1.06); } 26% { opacity: 1; transform: none; } 80% { opacity: 1; transform: none; } 100% { opacity: 0; transform: none; } }
  @keyframes intro-img { 0%, 8% { opacity: 0; transform: translateY(28px) scale(.97); } 40%, 80% { opacity: var(--peak); transform: none; } 100% { opacity: 0; transform: translateY(10px); } }

  /* Narrow screens: no free space beside the text, so the portrait becomes a dimmed backdrop and text gets a halo */
  @media (max-width: 999px) {
    .intro-stage { right: 0; top: 2.5rem; }
    .intro-stage img { --peak: .35; }
    .intro-frame { display: none; }
    .hero.intro-on > .wrap h1, .hero.intro-on > .wrap p { text-shadow: 0 1px 14px rgba(19, 32, 46, .95), 0 0 3px rgba(19, 32, 46, .9); }
  }
}
