/**
 * templates/templates.css
 * Visual identity for each portfolio template. Loaded by any page that
 * renders a portfolio — the Builder's live preview now, and the public
 * portfolio page (portfolio.html) once Phase 9 exists.
 *
 * All five templates — Minimal, Creative, Professional, Tech, Editorial —
 * are fully implemented, each with its own genuinely distinct system per
 * DESIGN.md. None of them share a hero layout, a heading treatment, or a
 * meta-string format; that repetition was the main critique to fix here.
 */

/* ---- Shared: avatar / profile photo ------------------------------------ */
/* Used by every template via tplAvatar() in templates.js. An <img> and its
   same-size initials fallback sit in the same wrapper; the fallback is
   revealed automatically on image load failure (bad Drive permissions,
   dead link, no photo at all) so a broken photo never leaves a blank gap. */

.tpl-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.tpl-avatar-img,
.tpl-avatar-fallback {
  display: block;
  object-fit: cover;
}

.tpl-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.tpl-avatar-sm { width: 44px; height: 44px; border-radius: 50%; font-size: 14px; }
.tpl-avatar-md { width: 72px; height: 72px; border-radius: 50%; font-size: 20px; }
.tpl-avatar-lg { width: 140px; height: 140px; border-radius: 6px; font-size: 34px; }
.tpl-avatar-xl { width: 168px; height: 210px; border-radius: 4px; font-size: 40px; }

/* ---- Shared: social platform badges -------------------------------------- */
/* Small monogram badges (not brand logos — see tplSocialBadge() in
   templates.js) shown inline before a social link's platform name. */

.tpl-social-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--tpl-accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  vertical-align: -4px;
  line-height: 1;
}

.tpl-social-badge-generic {
  background: none;
  border: 1.5px solid currentColor;
  color: inherit;
}

/* ---- Template 1: Minimal ---------------------------------------------- */
/* IT professionals, consultants, analysts, executives, developers.
   Clean, editorial, white background, restrained typography. See DESIGN.md. */

.tpl-minimal {
  --tpl-accent: #3A5A8C; /* overridden inline per-user via style="--tpl-accent: ..." */
  font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #16181D;
  background: #FFFFFF;
  line-height: 1.55;
}

.tpl-minimal .tpl-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 30px;
}

.tpl-minimal .tpl-avatar-fallback,
.tpl-minimal .tpl-avatar-img {
  border: 1px solid #E6E6E3;
}

.tpl-minimal .tpl-name {
  font-size: 32px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.015em;
  line-height: 1.1;
}

.tpl-minimal .tpl-title {
  font-size: 16px;
  color: #4A4F58;
  margin: 0 0 4px;
}

.tpl-minimal .tpl-location {
  font-size: 13px;
  color: #6C7078;
  margin: 0;
}

.tpl-minimal .tpl-section {
  padding-top: 22px;
  margin-top: 22px;
  border-top: 1px solid #E6E6E3;
}

.tpl-minimal .tpl-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #16181D;
  margin: 0 0 14px;
}

.tpl-minimal .tpl-heading::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 2px;
  background: var(--tpl-accent);
}

.tpl-minimal .tpl-bio {
  font-size: 15px;
  margin: 0;
  max-width: 62ch;
}

.tpl-minimal .tpl-skill-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tpl-minimal .tpl-skill-list li {
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px solid var(--tpl-accent);
}

.tpl-minimal .tpl-entry {
  margin-bottom: 18px;
}

.tpl-minimal .tpl-entry:last-child {
  margin-bottom: 0;
}

.tpl-minimal .tpl-entry-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 2px;
}

.tpl-minimal .tpl-entry-meta {
  font-size: 13px;
  color: #6C7078;
  margin: 0 0 6px;
}

.tpl-minimal .tpl-entry-desc {
  font-size: 14px;
  margin: 0;
  max-width: 62ch;
}

.tpl-minimal .tpl-link {
  color: var(--tpl-accent);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid var(--tpl-accent);
  transition: opacity 0.15s ease;
}

.tpl-minimal .tpl-link:hover {
  opacity: 0.7;
}

.tpl-minimal .tpl-contact-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 14px;
}

.tpl-minimal .tpl-contact-list li {
  margin-bottom: 6px;
}

.tpl-minimal .tpl-empty-note {
  font-size: 13px;
  color: #9A9EA5;
  font-style: italic;
}

/* ---- Template 2: Creative ---------------------------------------------- */
/* Photographers, designers, content creators, artists, videographers.
   Dark canvas, bold color-block accent, image-forward, asymmetric. */

.tpl-creative {
  --tpl-accent: #3A5A8C;
  font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0E0E10;
  color: #F2F0EC;
  padding: 4px;
}

.tpl-creative .tpl-c-hero {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 32px;
  padding-bottom: 26px;
  border-bottom: 1px solid rgba(242, 240, 236, 0.14);
}

.tpl-creative .tpl-avatar-fallback {
  font-family: 'Bricolage Grotesque', sans-serif;
}

.tpl-creative .tpl-c-name {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 36px;
  font-weight: 800;
  margin: 0 0 4px;
  line-height: 1.02;
  letter-spacing: -0.01em;
}

.tpl-creative .tpl-c-title { font-size: 15px; color: #C9C6BF; margin: 0 0 4px; }
.tpl-creative .tpl-c-location { font-size: 12px; color: #8C8A85; margin: 0; }
.tpl-creative .tpl-c-section { margin-bottom: 26px; }

.tpl-creative .tpl-c-heading {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 19px;
  font-weight: 700;
  color: #F2F0EC;
  margin: 0 0 14px;
}

.tpl-creative .tpl-c-bio { font-size: 15px; max-width: 60ch; color: #E4E1DA; }

.tpl-creative .tpl-c-skill-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; }
.tpl-creative .tpl-c-skill { background: var(--tpl-accent); color: #0E0E10; font-weight: 700; font-size: 12px; padding: 6px 12px; }
.tpl-creative .tpl-c-skill-row span { color: #C9C6BF; }

.tpl-creative .tpl-c-project-grid { display: flex; flex-wrap: wrap; gap: 14px; }
.tpl-creative .tpl-c-project {
  flex: 1 1 240px;
  min-height: 170px;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
  padding: 0;
  transition: transform 0.2s ease;
}
.tpl-creative .tpl-c-project:hover {
  transform: scale(1.015);
}
.tpl-creative .tpl-c-project-label {
  background: rgba(14, 14, 16, 0.72);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  margin: 14px;
}

.tpl-creative .tpl-c-entry { margin-bottom: 14px; font-size: 14px; }
.tpl-creative .tpl-c-entry strong { display: block; font-size: 14px; color: #F2F0EC; }
.tpl-creative .tpl-c-entry span { font-size: 12px; color: #8C8A85; }
.tpl-creative .tpl-c-link { color: var(--tpl-accent); font-weight: 700; text-decoration: none; transition: opacity 0.15s ease; }
.tpl-creative .tpl-c-link:hover { opacity: 0.75; }

/* ---- Template 3: Professional ------------------------------------------ */
/* Consultants, managers, administrators, business professionals, job seekers.
   Structured, credibility-focused, a real chronological timeline. */

.tpl-professional {
  --tpl-accent: #1F3A5F;
  font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #FAFAFA;
  color: #1A2233;
}

.tpl-professional .tpl-p-hero { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.tpl-professional .tpl-avatar-fallback,
.tpl-professional .tpl-avatar-img { box-shadow: 0 0 0 3px color-mix(in srgb, var(--tpl-accent) 18%, transparent); }
.tpl-professional .tpl-p-name { font-family: 'Source Serif 4', serif; font-size: 27px; font-weight: 600; margin: 0 0 2px; }
.tpl-professional .tpl-p-title { font-size: 15px; color: #4B5568; margin: 0 0 4px; }
.tpl-professional .tpl-p-location { font-size: 13px; color: #6B7280; margin: 0; }
.tpl-professional .tpl-p-rule { border: none; border-top: 2px solid var(--tpl-accent); margin: 0 0 24px; }
.tpl-professional .tpl-p-section { margin-bottom: 24px; }

.tpl-professional .tpl-p-heading {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--tpl-accent); margin: 0 0 12px;
}
.tpl-professional .tpl-p-heading::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--tpl-accent);
}

.tpl-professional .tpl-p-bio { font-size: 14px; max-width: 64ch; margin: 0; }

.tpl-professional .tpl-p-skills { font-size: 13px; color: #374151; margin: 0; }
.tpl-professional .tpl-p-skills span:not(:last-child)::after { content: " · "; color: #8B8272; }

.tpl-professional .tpl-p-timeline { border-left: 2px solid #E4E1D9; margin-left: 4px; padding-left: 20px; }
.tpl-professional .tpl-p-entry { position: relative; margin-bottom: 16px; }
.tpl-professional .tpl-p-entry:last-child { margin-bottom: 0; }
.tpl-professional .tpl-p-entry::before {
  content: ""; position: absolute; left: -25px; top: 4px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--tpl-accent);
}
.tpl-professional .tpl-p-entry-title { font-size: 14px; font-weight: 600; margin: 0 0 2px; }
.tpl-professional .tpl-p-entry-meta { font-size: 12px; color: #6B7280; margin: 0 0 4px; }
.tpl-professional .tpl-p-entry-desc { font-size: 13px; margin: 0; max-width: 62ch; }

.tpl-professional .tpl-p-contact { font-size: 13px; margin: 0; }
.tpl-professional .tpl-p-link { color: var(--tpl-accent); text-decoration: none; font-weight: 600; transition: opacity 0.15s ease; }
.tpl-professional .tpl-p-link:hover { opacity: 0.7; }

/* ---- Template 4: Tech --------------------------------------------------- */
/* Developers, engineers, cybersecurity, data professionals.
   Controlled light/dark surfaces (toggle button on the page itself);
   monospace reserved only for genuinely technical labels — no neon. */

.tpl-tech {
  --tpl-accent: #4FA6C7;
  font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #F5F6F8;
  color: #171A20;
  border: 1px solid #E1E4E9;
  padding: 26px;
}

.tpl-tech.theme-dark { background: #12151A; color: #E7E9ED; border-color: #262B33; }

.tpl-tech .tpl-t-top { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; flex-wrap: wrap; }
.tpl-tech .tpl-t-top-text { flex: 1; min-width: 140px; }
.tpl-tech .tpl-avatar-img { filter: grayscale(55%) contrast(1.05); }
.tpl-tech .tpl-avatar-tech { border-radius: 8px; }
.tpl-tech .tpl-avatar-fallback { border-radius: 8px; font-family: 'JetBrains Mono', monospace; }
.tpl-tech .tpl-t-name { font-size: 22px; font-weight: 700; margin: 0 0 2px; }
.tpl-tech .tpl-t-title { font-size: 13px; color: #5B6270; margin: 0; }
.tpl-tech.theme-dark .tpl-t-title { color: #9AA2AF; }

.tpl-tech .tpl-t-toggle {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: none;
  border: 1px solid #C7CBD1;
  color: inherit;
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 4px;
  transition: border-color 0.15s ease;
}
.tpl-tech.theme-dark .tpl-t-toggle { border-color: #3A404B; }
.tpl-tech .tpl-t-toggle:hover { border-color: var(--tpl-accent); }

.tpl-tech .tpl-t-section { margin-bottom: 20px; }
.tpl-tech .tpl-t-heading {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--tpl-accent);
  margin: 0 0 10px;
}
.tpl-tech.theme-dark .tpl-t-heading { color: var(--tpl-accent); }

.tpl-tech .tpl-t-tag-row { display: flex; flex-wrap: wrap; gap: 12px; font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.tpl-tech .tpl-t-tag { color: var(--tpl-accent); }

.tpl-tech .tpl-t-project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tpl-tech .tpl-t-project { border: 1px solid #E1E4E9; padding: 14px; border-radius: 4px; transition: border-color 0.15s ease; }
.tpl-tech .tpl-t-project:hover { border-color: var(--tpl-accent); }
.tpl-tech.theme-dark .tpl-t-project { border-color: #262B33; }
.tpl-tech .tpl-t-project-name { font-size: 14px; font-weight: 600; margin: 0 0 6px; }
.tpl-tech .tpl-t-project-desc { font-size: 13px; margin: 0 0 8px; color: #4A505A; }
.tpl-tech.theme-dark .tpl-t-project-desc { color: #AEB4BE; }
.tpl-tech .tpl-t-stack { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--tpl-accent); margin: 0 0 6px; }

.tpl-tech .tpl-t-entry { margin-bottom: 12px; font-size: 13px; }
.tpl-tech .tpl-t-entry strong { display: block; font-size: 13.5px; }
.tpl-tech .tpl-t-entry span { font-size: 12px; color: #5B6270; }
.tpl-tech.theme-dark .tpl-t-entry span { color: #9AA2AF; }
.tpl-tech .tpl-t-link { color: var(--tpl-accent); text-decoration: none; font-size: 13px; transition: opacity 0.15s ease; }
.tpl-tech .tpl-t-link:hover { opacity: 0.75; }

/* ---- Template 5: Editorial ----------------------------------------------- */
/* Writers, strategists, researchers, personal brands.
   Magazine-inspired: large serif display, italic pull-quote bio, folio list. */

.tpl-editorial {
  --tpl-accent: #8B3A2B;
  font-family: 'Source Serif 4', serif;
  background: #F6F1E8;
  color: #1C1A17;
}

.tpl-editorial .tpl-e-hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 22px; }
.tpl-editorial .tpl-avatar-editorial { box-shadow: 0 6px 18px rgba(28, 26, 23, 0.14); }
.tpl-editorial .tpl-avatar-fallback { font-family: 'Source Serif 4', serif; font-style: italic; }
.tpl-editorial .tpl-e-name { font-size: 38px; font-weight: 600; margin: 0 0 2px; line-height: 1.08; }
.tpl-editorial .tpl-e-title { font-size: 16px; font-style: italic; color: #5A5248; margin: 0 0 6px; }
.tpl-editorial .tpl-e-location { font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--tpl-accent); margin: 0; }
.tpl-editorial .tpl-e-rule { border: none; border-top: 1px solid #D8CFC0; margin: 0 0 24px; }

.tpl-editorial .tpl-e-bio {
  font-size: 18px; font-style: italic; line-height: 1.5;
  padding-left: 20px; border-left: 3px solid var(--tpl-accent);
  margin: 0 0 30px; max-width: 56ch;
}

.tpl-editorial .tpl-e-section { margin-bottom: 28px; }
.tpl-editorial .tpl-e-heading {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--tpl-accent); margin: 0 0 14px;
}
.tpl-editorial .tpl-e-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #D8CFC0;
}

.tpl-editorial .tpl-e-skill-row { font-size: 14px; margin: 0; }
.tpl-editorial .tpl-e-skill-row span:not(:last-child)::after { content: " — "; color: var(--tpl-accent); }

.tpl-editorial .tpl-e-folio-item { display: flex; gap: 16px; margin-bottom: 16px; }
.tpl-editorial .tpl-e-folio-num { font-size: 13px; color: var(--tpl-accent); flex-shrink: 0; padding-top: 3px; }
.tpl-editorial .tpl-e-folio-title { font-size: 16px; font-weight: 600; margin: 0 0 2px; }
.tpl-editorial .tpl-e-folio-desc { font-size: 14px; color: #4A443C; margin: 0; max-width: 58ch; }

.tpl-editorial .tpl-e-entry { margin-bottom: 14px; font-size: 14px; }
.tpl-editorial .tpl-e-entry strong { display: block; font-size: 15px; }
.tpl-editorial .tpl-e-entry span { font-size: 12px; color: #8B7E6E; }
.tpl-editorial .tpl-e-link { color: var(--tpl-accent); text-decoration: underline; transition: opacity 0.15s ease; }
.tpl-editorial .tpl-e-link:hover { opacity: 0.7; }