/* ==========================================================================
   Meridian Digital Studios — stylesheet
   --------------------------------------------------------------------------
   Business name note: CSS can't inject text content into the page in an
   accessible/SEO-safe way, so the business name itself lives in ONE place —
   the BUSINESS_NAME constant at the top of js/script.js — and the head meta
   tags in index.html. This file only controls the *design* (colors, type,
   spacing). Change the palette below and the whole site updates.
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  /* Palette: deep navy/charcoal + warm off-white + a single confident accent.
     Deliberately not "startup blue/purple gradient". */
  --color-ink: #14181f;          /* near-black, body text */
  --color-navy: #101826;         /* deep navy, header/footer/dark sections */
  --color-navy-soft: #1b2436;    /* lighter navy for cards on dark bg */
  --color-cream: #faf7f2;        /* warm off-white, page background */
  --color-cream-dim: #f1ebe1;    /* slightly deeper cream for section bands */
  --color-line: #e4ddd0;         /* hairline borders on light bg */
  --color-line-dark: #2a3346;    /* hairline borders on dark bg */
  --color-accent: #c65d2e;       /* burnt terracotta — the one accent color */
  --color-accent-dark: #a44a22;
  --color-muted: #5c6270;

  --font-display: "Iowan Old Style", "Georgia", "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-card: 0 1px 2px rgba(20, 24, 31, 0.04), 0 8px 24px rgba(20, 24, 31, 0.06);
  --shadow-card-hover: 0 4px 10px rgba(20, 24, 31, 0.06), 0 16px 32px rgba(20, 24, 31, 0.1);

  --max-width: 1140px;
  --transition: 180ms ease;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--color-ink);
  background: var(--color-cream);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
ul { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; margin: 0; }
p { margin: 0; }

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.section-title {
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  margin-bottom: 8px;
}
.section-sub {
  color: var(--color-muted);
  font-size: 1.05rem;
  max-width: 60ch;
  margin-bottom: 40px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.98rem;
  border: 1px solid transparent;
  transition: transform var(--transition), background var(--transition), border-color var(--transition), color var(--transition);
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: var(--color-accent);
  color: #fff;
}
.btn-primary:hover { background: var(--color-accent-dark); }
.btn-ghost {
  background: transparent;
  border-color: currentColor;
  color: inherit;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 247, 242, 0.9);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--color-line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.logo { display: flex; align-items: center; }
.logo-img { display: block; height: 34px; width: auto; }
@media (max-width: 400px) {
  .logo-img { height: 28px; }
}
.main-nav {
  display: none;
  align-items: center;
  gap: 32px;
  font-size: 0.95rem;
  font-weight: 500;
}
.main-nav a { transition: color var(--transition); }
.main-nav a:hover { color: var(--color-accent); }
.nav-cta {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  background: var(--color-navy);
  color: #fff !important;
}
.nav-cta:hover { background: var(--color-accent) !important; }

.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  padding: 0;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-ink);
  transition: transform var(--transition), opacity var(--transition);
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mobile-nav {
  display: none;
  flex-direction: column;
  border-top: 1px solid var(--color-line);
  background: var(--color-cream);
}
.mobile-nav.is-open { display: flex; }
.mobile-nav a {
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-line);
  font-weight: 500;
}

@media (min-width: 860px) {
  .main-nav { display: flex; }
  .nav-toggle { display: none; }
  .mobile-nav { display: none !important; }
}

/* ---------- Reusable dark-section texture ----------
   Subtle gradient glow + faint grain, layered behind a section's content
   via ::before/::after. Applied to .hero and .contact (both dark navy) so
   they don't read as flat solid color. Add/remove the "section-texture"
   class on any dark section to reuse this. */
.section-texture {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}
.section-texture::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 900px 520px at 12% -10%, rgba(198, 93, 46, 0.18), transparent 60%),
    radial-gradient(ellipse 700px 520px at 105% 110%, rgba(255, 255, 255, 0.05), transparent 55%);
}
.section-texture::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}
.section-texture > * { position: relative; z-index: 1; }

/* ---------- Browser-frame component ----------
   Small "browser chrome" wrapper used for the hero mockup and the Web
   Design service card visual — a real screenshot dropped in an <img>. */
.browser-frame {
  background: #fff;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.2);
}
.browser-frame-bar {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  background: #e8e2d6;
}
.browser-frame-bar span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(16, 24, 38, 0.18);
}
.browser-frame img { display: block; width: 100%; }

/* Hero mockup only: render the top-bar dots as classic macOS traffic-light
   window controls (red/yellow/green) instead of the plain neutral dots
   used elsewhere (e.g. the Web Design service card mockup). */
.browser-frame--hero .browser-frame-bar span:nth-child(1) { background: #ff5f57; }
.browser-frame--hero .browser-frame-bar span:nth-child(2) { background: #febc2e; }
.browser-frame--hero .browser-frame-bar span:nth-child(3) { background: #28c840; }

/* Hero mockup crossfade — fixed-aspect stage so the frame never resizes as
   screenshots swap; each image is absolutely stacked and faded via opacity. */
.hero-mockup-stage { position: relative; aspect-ratio: 900 / 633; }
.hero-mockup-img {
  position: absolute;
  inset: 0;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.7s ease;
}
.hero-mockup-img.is-active { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .hero-mockup-img { transition: none; }
}

.browser-frame--card { border-radius: var(--radius-md); box-shadow: none; border: 1px solid var(--color-line); }
.browser-frame--card .browser-frame-bar { padding: 7px 10px; }
.browser-frame--card .browser-frame-bar span { width: 6px; height: 6px; }
.browser-frame-crop { height: 92px; overflow: hidden; }
.browser-frame-crop img { object-fit: cover; object-position: top; height: 100%; }

/* ---------- Hero ---------- */
.hero {
  background: var(--color-navy);
  color: #fff;
  padding: 100px 0 90px;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 48px;
  align-items: center;
}
@media (min-width: 960px) {
  .hero-grid { grid-template-columns: 1.05fr 1fr; gap: 56px; }
}
.hero-copy { max-width: 560px; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-accent);
  margin-bottom: 18px;
}
.hero h1 {
  font-size: clamp(2.1rem, 4.4vw, 3.2rem);
  margin-bottom: 22px;
}
.hero .accent { color: var(--color-accent); }
.hero-sub {
  font-size: 1.15rem;
  color: rgba(255, 255, 255, 0.75);
  max-width: 52ch;
  margin-bottom: 36px;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; }
.hero .btn-ghost { border-color: rgba(255, 255, 255, 0.4); }
.hero-proof {
  margin-top: 22px;
  font-size: 0.88rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.02em;
}
.hero-mockup { display: flex; justify-content: center; }
.browser-frame--hero {
  width: 100%;
  max-width: 460px;
  transform: rotate(-1.2deg);
}

/* ---------- Services ---------- */
.services { padding: 90px 0; }
.services-primary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
@media (min-width: 700px) {
  .services-primary { grid-template-columns: 1fr 1fr; }
}
.service-card {
  background: #fff;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  transition: box-shadow var(--transition), transform var(--transition);
}
.service-card--primary {
  padding: 36px 32px;
  box-shadow: var(--shadow-card);
}
.service-card--primary:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}
.service-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--color-cream-dim);
  color: var(--color-accent);
  margin-bottom: 18px;
}
.service-icon svg { width: 24px; height: 24px; }
.service-card--primary h3 { font-size: 1.4rem; margin-bottom: 10px; }
.service-card--primary p { color: var(--color-muted); }

/* Visual replacements for the two primary service cards */
.service-visual { margin-bottom: 22px; }
.service-visual--browser svg { width: 130px; height: auto; display: block; }
.service-visual--chart svg { width: 130px; height: auto; display: block; }

.services-secondary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 700px) {
  .services-secondary { grid-template-columns: repeat(3, 1fr); }
}
.service-card--secondary {
  padding: 22px 24px;
  background: var(--color-cream-dim);
  border-color: var(--color-line);
}
.service-card--secondary:hover {
  box-shadow: var(--shadow-card);
  transform: translateY(-2px);
}
.service-card--secondary h4 {
  font-size: 1.02rem;
  margin-bottom: 6px;
}
.service-card--secondary p {
  color: var(--color-muted);
  font-size: 0.92rem;
}

/* ---------- Portfolio ---------- */
.portfolio { padding: 90px 0; background: var(--color-cream-dim); }

.portfolio-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}
@media (min-width: 900px) {
  .portfolio-layout { grid-template-columns: 300px 1fr; align-items: start; }
}

.portfolio-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
@media (min-width: 900px) {
  .portfolio-list { grid-template-columns: 1fr; }
}

.portfolio-item {
  display: block;
  width: 100%;
  height: auto;
  /* Prevent CSS Grid's default row-stretch behavior: with overflow:hidden
     below, a stretched/miscalculated grid height would clip wrapped category
     text (e.g. "Catering / cafe") instead of the card growing to fit it. */
  align-self: start;
  text-align: left;
  background: #fff;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  overflow: hidden;
  padding: 0;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.portfolio-item:hover { border-color: var(--color-accent); }
.portfolio-item.is-active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(198, 93, 46, 0.18);
}
.portfolio-item img {
  /* display:block matters here: <img> defaults to inline, which gives it a
     baseline-aligned line box shorter than its own rendered height — the
     card body below would then overlap up into the image and get clipped
     by this card's overflow:hidden. Block avoids that mismatch entirely. */
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top;
  background: var(--color-cream-dim);
}
/* Bottom padding slightly larger than the top so a wrapped second line of
   category text (e.g. "Catering / cafe") still gets breathing room above
   the card's border, not just a tight single-line fit.
   display:block on all three matters: these are <span> elements in the
   generated markup (see js/script.js), and vertical padding/margin on an
   inline box doesn't reliably participate in normal block flow — that
   mismatch was the actual cause of the card-height/clipping bug, not the
   grid or the image. Block makes the box model behave as the CSS expects. */
.portfolio-item-body { display: block; padding: 12px 14px 16px; }
.portfolio-item-name { display: block; font-weight: 600; font-size: 0.98rem; }
.portfolio-item-category {
  display: block;
  color: var(--color-muted);
  font-size: 0.85rem;
  line-height: 1.4;
  margin-top: 2px;
}

.portfolio-preview {
  background: #fff;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-card);
}
.preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.viewport-toggle {
  display: inline-flex;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.viewport-btn {
  background: #fff;
  border: none;
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-muted);
  transition: background var(--transition), color var(--transition);
}
.viewport-btn + .viewport-btn { border-left: 1px solid var(--color-line); }
.viewport-btn.is-active {
  background: var(--color-navy);
  color: #fff;
}
.open-new-tab {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-accent);
}
.open-new-tab:hover { text-decoration: underline; }

.preview-frame-wrap {
  background: var(--color-cream-dim);
  border-radius: var(--radius-md);
  min-height: 320px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  padding: 16px;
}
.preview-frame-wrap iframe {
  border: none;
  width: 100%;
  height: 560px;
  background: #fff;
  border-radius: var(--radius-sm);
  transition: width var(--transition);
}
/* Mobile viewport mode: narrow the iframe and frame it like a phone */
.preview-frame-wrap.is-mobile iframe {
  width: 375px;
  max-width: 100%;
  height: 640px;
  border: 10px solid var(--color-navy);
  border-radius: 24px;
}
.preview-current {
  margin-top: 12px;
  color: var(--color-muted);
  font-size: 0.88rem;
}
.noscript-note {
  padding: 20px;
  color: var(--color-muted);
}

/* Fallback link list: hidden once JS confirms the interactive preview works */
.portfolio-fallback {
  margin-top: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
}
.portfolio-fallback a {
  font-weight: 600;
  color: var(--color-accent);
  font-size: 0.92rem;
}
.portfolio-fallback a:hover { text-decoration: underline; }
.portfolio-fallback.is-hidden { display: none; }

/* ---------- About ---------- */
.about { padding: 90px 0; }
.about-lead {
  font-size: 1.1rem;
  color: var(--color-muted);
  max-width: 62ch;
  margin-bottom: 40px;
}
.about-highlights {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 700px) {
  .about-highlights { grid-template-columns: repeat(3, 1fr); }
}
.about-highlight {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background: #fff;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  transition: transform var(--transition), box-shadow var(--transition);
}
.about-highlight:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}
.about-highlight-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--color-cream-dim);
  color: var(--color-accent);
}
.about-highlight-icon svg { width: 20px; height: 20px; }
.about-highlight p { font-size: 0.95rem; color: var(--color-ink); }
.about-highlight strong { font-weight: 600; }

/* ---------- Contact ---------- */
.contact {
  padding: 90px 0;
  background: var(--color-navy);
  color: #fff;
}
.contact .section-sub { color: rgba(255, 255, 255, 0.7); }
.contact-inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: 48px;
}
@media (min-width: 860px) {
  .contact-inner { grid-template-columns: 1fr 1.1fr; }
}
.contact-methods { margin-top: 28px; display: flex; flex-direction: column; gap: 16px; }
.contact-methods li { display: flex; flex-direction: column; gap: 2px; }
.contact-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
}
.contact-methods a {
  font-size: 1.25rem;
  font-weight: 600;
  transition: color var(--transition);
}
.contact-methods a:hover { color: var(--color-accent); }

.contact-form {
  background: var(--color-navy-soft);
  border: 1px solid var(--color-line-dark);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
/* This form's own "display: flex" above would otherwise beat the browser's
   default [hidden] { display: none }, since author styles always win over
   user-agent ones regardless of specificity — so it needs an explicit
   override to actually disappear once initContactForm() hides it. */
.contact-form[hidden] { display: none; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 0.88rem; color: rgba(255, 255, 255, 0.75); }
.form-row input,
.form-row textarea {
  background: var(--color-navy);
  border: 1px solid var(--color-line-dark);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: #fff;
  font: inherit;
  resize: vertical;
  transition: border-color var(--transition);
}
.form-row input:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--color-accent);
}
.contact-form .btn-primary { align-self: flex-start; }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Swapped in for .contact-form after a successful AJAX submit (see
   initContactForm in js/script.js) — same card treatment as the form
   it replaces, so nothing jumps in size or position. */
.contact-form-success {
  background: var(--color-navy-soft);
  border: 1px solid var(--color-line-dark);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
}
.contact-form-success h3 { font-size: 1.4rem; margin-bottom: 8px; }
.contact-form-success p { color: rgba(255, 255, 255, 0.7); }

/* ---------- Thank-you page (Netlify Forms success redirect, see thanks.html) ---------- */
.thanks {
  padding: 160px 0;
  background: var(--color-navy);
  color: #fff;
  text-align: center;
}
.thanks .section-sub { color: rgba(255, 255, 255, 0.7); margin-left: auto; margin-right: auto; }
.thanks-actions { margin-top: 8px; }

/* ---------- Footer ---------- */
.site-footer {
  padding: 28px 0;
  background: var(--color-navy);
  border-top: 1px solid var(--color-line-dark);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.9rem;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.footer-brand { display: flex; align-items: center; gap: 10px; }
.footer-logo-img { display: block; height: 22px; width: auto; }
.footer-socials { display: flex; gap: 20px; }
.footer-socials a { transition: color var(--transition); }
.footer-socials a:hover { color: #fff; }

/* ---------- Focus visibility (accessibility) ---------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ---------- Scroll-triggered entrance animation ----------
   Elements marked [data-animate] in the HTML start hidden/offset; js/script.js
   uses an IntersectionObserver to add "is-visible" as each one enters the
   viewport. Purely CSS transitions — no animation library. Users with
   prefers-reduced-motion get everything shown immediately (see script.js and
   the reduced-motion block near the top of this file). */
[data-animate] {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 700ms ease, transform 700ms ease;
}
[data-animate].is-visible {
  opacity: 1;
  transform: translateY(0);
}
