/* =============================================================================
   The David Company — v2
   Theme is controlled by [data-theme] on <html>. Switch the variable set
   below (or set TDC_CONFIG.theme / ?theme=) to move between dark and light.
   ============================================================================= */

:root,
[data-theme="dark"] {
  --bg: #0c0c0c;
  --bg-elev: #161616;
  --text: #f3f3f1;
  --muted: #9a9a96;
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.28);
  --btn-bg: #f3f3f1;
  --btn-text: #0c0c0c;
  --btn-bg-hover: #ffffff;
  --danger: #e07070;
  --success: #b8d4b8;
  --focus: #ffffff;
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  --theme-color: #0c0c0c;
}

[data-theme="light"] {
  --bg: #f3f3f1;
  --bg-elev: #ffffff;
  --text: #141414;
  --muted: #5c5c58;
  --line: rgba(0, 0, 0, 0.14);
  --line-strong: rgba(0, 0, 0, 0.32);
  --btn-bg: #141414;
  --btn-text: #f3f3f1;
  --btn-bg-hover: #000000;
  --danger: #b42323;
  --success: #1f6b3a;
  --focus: #141414;
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.12);
  --theme-color: #f3f3f1;
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

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

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  font-weight: 400;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

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

/* Theme switch — discreet, top-right */
.theme-switch {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 20;
  display: flex;
  gap: 14px;
}

.theme-switch button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
}

.theme-switch button[aria-pressed="true"] {
  color: var(--text);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

.theme-switch button:hover {
  color: var(--text);
}

.theme-switch button:focus-visible {
  outline: 1px solid var(--focus);
  outline-offset: 4px;
}

/* Portal stage */
.portal {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 48px 24px;
}

.stage {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto minmax(200px, 1fr);
  align-items: center;
  column-gap: 48px;
  width: min(1080px, 100%);
}

.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.logo {
  width: 248px;
  height: auto;
}

.logo-light {
  display: none;
}

[data-theme="light"] .logo-dark {
  display: none;
}

[data-theme="light"] .logo-light {
  display: block;
}

.tagline {
  margin: 20px 0 0;
  max-width: 20em;
  font-size: 1.05rem;
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: 0.01em;
  color: var(--text);
}

.subline {
  margin: 10px 0 0;
  max-width: 26em;
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.btn-contact,
.btn-submit {
  appearance: none;
  border: 0;
  background: var(--btn-bg);
  color: var(--btn-text);
  padding: 0.7rem 1.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 0;
  transition: background 0.15s ease, transform 0.15s ease;
}

.btn-contact {
  margin-top: 22px;
}

.btn-contact:hover,
.btn-submit:hover {
  background: var(--btn-bg-hover);
}

.btn-contact:focus-visible,
.btn-submit:focus-visible,
.panel-close:focus-visible {
  outline: 1px solid var(--focus);
  outline-offset: 3px;
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: none;
  border-bottom-color: var(--text);
}

.btn-submit:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Services flanking the mark */
.services {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.services-left {
  text-align: right;
}

.services-right {
  text-align: left;
}

.svc-label {
  display: block;
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.svc-note {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--muted);
  font-weight: 400;
}

footer {
  flex-shrink: 0;
  text-align: center;
  padding: 8px 24px 22px;
}

footer p {
  margin: 0;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* Contact panel */
.panel[hidden] {
  display: none;
}

.panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

[data-theme="light"] .panel-backdrop {
  background: rgba(20, 20, 20, 0.28);
}

.panel-dialog {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  max-height: calc(100dvh - 48px);
  overflow: auto;
  background: var(--bg-elev);
  color: var(--text);
  padding: 32px 32px 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.panel-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  padding: 4px 6px;
}

.panel-close:hover {
  color: var(--text);
}

#contact-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.panel-lede {
  margin: 6px 0 22px;
  font-size: 0.875rem;
  color: var(--muted);
}

.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.field {
  margin: 0 0 16px;
}

.field label {
  display: block;
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 500;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 6px 0 8px;
  color: var(--text);
  appearance: none;
}

.field select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%239a9a96' stroke-width='1.2' d='M1 1.5 L6 6.5 L11 1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0 center;
  padding-right: 20px;
}

.field textarea {
  resize: vertical;
  min-height: 5.5rem;
  line-height: 1.45;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-bottom-color: var(--line-strong);
}

.field.is-invalid input,
.field.is-invalid select,
.field.is-invalid textarea {
  border-bottom-color: var(--danger);
}

.field-error {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: var(--danger);
}

.btn-submit {
  width: 100%;
  margin-top: 8px;
}

.form-status {
  margin: 0 0 14px;
  font-size: 0.875rem;
  line-height: 1.45;
}

.form-status.is-success {
  color: var(--success);
}

.form-status.is-error {
  color: var(--danger);
}

.form-status.is-fallback {
  color: var(--muted);
}

.form-status a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

body.panel-open {
  overflow: hidden;
}

/* Mobile / narrow */
@media (max-width: 860px) {
  .theme-switch {
    top: 12px;
    right: 16px;
  }

  .portal {
    padding: 64px 24px 16px;
    align-items: flex-start;
  }

  .stage {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 24px;
    row-gap: 22px;
    width: 100%;
    align-items: start;
  }

  .center {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .services-left,
  .services-right {
    display: contents;
    text-align: left;
  }

  .services-left li:nth-child(1) { grid-column: 1; grid-row: 2; }
  .services-left li:nth-child(2) { grid-column: 1; grid-row: 3; }
  .services-left li:nth-child(3) { grid-column: 1; grid-row: 4; }
  .services-right li:nth-child(1) { grid-column: 2; grid-row: 2; }
  .services-right li:nth-child(2) { grid-column: 2; grid-row: 3; }
  .services-right li:nth-child(3) { grid-column: 2; grid-row: 4; }

  .logo {
    width: 200px;
  }

  .tagline {
    font-size: 0.95rem;
    margin-top: 16px;
    max-width: 18em;
  }

  .subline {
    font-size: 0.75rem;
    max-width: 22em;
  }

  .btn-contact {
    margin-top: 18px;
  }
}

@media (max-width: 420px) {
  .portal {
    padding: 56px 20px 12px;
  }

  .logo {
    width: 188px;
  }

  .stage {
    grid-template-columns: 1fr;
    row-gap: 16px;
  }

  .center {
    grid-column: 1;
    margin-bottom: 8px;
  }

  .services-left,
  .services-right {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .services-left { grid-column: 1; grid-row: 2; }
  .services-right { grid-column: 1; grid-row: 3; }

  .services-left li:nth-child(1),
  .services-left li:nth-child(2),
  .services-left li:nth-child(3),
  .services-right li:nth-child(1),
  .services-right li:nth-child(2),
  .services-right li:nth-child(3) {
    grid-column: auto;
    grid-row: auto;
  }

  .svc-label {
    font-size: 0.875rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn-contact,
  .btn-submit {
    transition: none;
  }
}

footer a {
  color: inherit;
  text-decoration: none;
}

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

footer p + p {
  margin-top: 6px;
}

/* Thanks / simple inner pages */
.thanks-main,
.simple-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 24px 24px;
  text-align: center;
}

.thanks-card,
.simple-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 28em;
}

.thanks-card .logo {
  width: 200px;
  margin-bottom: 28px;
}

.thanks-card h1,
.simple-card h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.thanks-card p,
.simple-card .lede {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.thanks-actions,
.simple-links {
  margin-top: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  justify-content: center;
  align-items: center;
}

.thanks-actions a,
.simple-links a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}

.thanks-actions a:hover,
.simple-links a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.btn-link {
  background: var(--btn-bg);
  color: var(--btn-text) !important;
  padding: 0.7rem 1.5rem;
  text-decoration: none !important;
}

.btn-link:hover {
  background: var(--btn-bg-hover);
  text-decoration: none !important;
}

.thanks-card a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}
