/* =========================================================
   PhysicianCodingGuide.com, "The Attending" design
   Palette: forest green, ivory, brass. Serif authority.
   ========================================================= */

:root {
  --forest:    #0D3B2E;
  --forest-2:  #0A2E24;
  --forest-3:  #145843;
  --ivory:     #FAF7F0;
  --brass:     #C9A227;
  --brass-dk:  #A8861C;
  --ink:       #1E2B24;
  --slate:     #3C4A42;
  --gray:      #6E7D74;
  --gray-lt:   #F2EFE7;
  --border:    #E5E1D4;
  --white:     #FFFFFF;
  --warn-bg:   #FBF6E7;
  --warn-bd:   #C9A227;
  --tip-bg:    #EFF5F0;
  --tip-bd:    #2E7D5B;
  --caution-bg:#FAF0EE;
  --caution-bd:#B0533F;
  --key-bg:    #EFF5F0;

  --font-body: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --font-ui:   -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Menlo', 'Consolas', 'Courier New', monospace;

  --max-w:  760px;
  --wide-w: 1080px;
  --radius: 6px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--ink);
  background: var(--ivory);
}

/* ---- SITE HEADER ---- */
.site-header { background: var(--forest); padding: 0 1.5rem; border-bottom: 1px solid rgba(250,247,240,.12); }
.site-header__inner {
  max-width: var(--wide-w); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; height: 62px;
}
.site-logo {
  color: var(--ivory); font-family: var(--font-body);
  font-size: 1.08rem; font-weight: 700; text-decoration: none; letter-spacing: .01em;
}
.site-logo span { color: var(--brass); font-style: italic; }
.site-nav { display: flex; gap: 1.7rem; }
.site-nav a {
  color: #B8C7BE; font-family: var(--font-ui); font-size: .78rem;
  letter-spacing: .1em; text-transform: uppercase; text-decoration: none; transition: color .15s;
}
.site-nav a:hover { color: var(--brass); }

/* ---- ARTICLE HERO ---- */
.article-hero {
  background: linear-gradient(170deg, var(--forest) 0%, var(--forest-2) 100%);
  color: var(--ivory); padding: 3.2rem 1.5rem 2.7rem;
}
.article-hero__inner { max-width: var(--max-w); margin: 0 auto; }
.article-hero__eyebrow {
  font-family: var(--font-ui); font-size: .72rem; font-weight: 700;
  letter-spacing: .22em; text-transform: uppercase; color: var(--brass); margin-bottom: .8rem;
}
.article-hero h1 {
  font-size: clamp(1.7rem, 4vw, 2.5rem); font-weight: 700; line-height: 1.12;
  margin-bottom: 1rem; letter-spacing: -.01em;
}
.article-hero__sub { font-family: var(--font-ui); font-size: 1.02rem; color: #CBD8D0; max-width: 580px; line-height: 1.7; }
.article-hero__sub a { color: var(--brass); }

/* ---- MAIN CONTENT ---- */
.article-body { max-width: var(--max-w); margin: 0 auto; padding: 2.6rem 1.5rem 4rem; }

.article-body h2 {
  font-family: var(--font-body); font-size: 1.45rem; font-weight: 700; color: var(--forest);
  margin: 2.6rem 0 .8rem; padding-bottom: .45rem; border-bottom: 2px solid var(--brass);
}
.article-body h3 {
  font-family: var(--font-ui); font-size: 1rem; font-weight: 700; color: var(--forest-3);
  margin: 1.8rem 0 .5rem; letter-spacing: .01em;
}
.article-body p { margin-bottom: 1.15rem; }
.article-body ul, .article-body ol { margin: .75rem 0 1.15rem 1.5rem; }
.article-body li { margin-bottom: .45rem; }
.article-body a { color: var(--forest-3); text-decoration-color: var(--brass); text-underline-offset: 2px; }
.article-body a:hover { color: var(--brass-dk); }
.article-body strong { color: var(--forest); }

/* ---- CALLOUT BOXES ---- */
.callout {
  border-radius: var(--radius); padding: 1.15rem 1.3rem; margin: 1.8rem 0;
  font-family: var(--font-ui); font-size: .92rem; line-height: 1.65;
  background: var(--white); border: 1px solid var(--border);
}
.callout--key     { background: var(--key-bg);   border-left: 4px solid var(--forest-3); }
.callout--warn    { background: var(--warn-bg);  border-left: 4px solid var(--warn-bd); }
.callout--tip     { background: var(--tip-bg);   border-left: 4px solid var(--tip-bd); }
.callout--caution { background: var(--caution-bg); border-left: 4px solid var(--caution-bd); }
.callout__label {
  font-size: .68rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  margin-bottom: .4rem; color: var(--forest);
}
.callout a { color: var(--forest-3); }

/* ---- DOLLAR HIGHLIGHT ---- */
.dollar-impact {
  background: linear-gradient(170deg, var(--forest) 0%, var(--forest-2) 100%);
  color: var(--ivory); border-radius: var(--radius);
  padding: 1.6rem 1.8rem; margin: 2rem 0; font-family: var(--font-ui);
  border: 1px solid var(--forest-3);
}
.dollar-impact__num {
  font-family: var(--font-body); font-size: 2.4rem; font-weight: 800; color: var(--brass);
  line-height: 1.05; margin-bottom: .4rem; letter-spacing: -.01em;
}
.dollar-impact__label { font-size: .88rem; color: #CBD8D0; line-height: 1.6; }

/* ---- CODE TABLE ---- */
.code-table {
  width: 100%; border-collapse: collapse;
  font-family: var(--font-ui); font-size: .88rem; margin: 1.25rem 0 1.8rem;
  background: var(--white);
}
.code-table th {
  background: var(--forest); color: var(--ivory);
  padding: .6rem .85rem; text-align: left; font-weight: 600; font-size: .82rem;
  letter-spacing: .03em;
}
.code-table td { padding: .55rem .85rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.code-table tr:nth-child(even) td { background: var(--gray-lt); }
.code-table .mono { font-family: var(--font-mono); color: var(--forest-3); font-weight: 700; }

/* ---- GUIDE NAV ---- */
.chapter-nav {
  display: flex; justify-content: space-between; gap: 1rem;
  margin: 3rem 0 0; padding-top: 2rem; border-top: 1px solid var(--border);
  font-family: var(--font-ui); font-size: .88rem;
}
.chapter-nav a {
  color: var(--forest-3); text-decoration: none;
  display: flex; flex-direction: column; gap: .25rem; max-width: 46%;
}
.chapter-nav a:hover { color: var(--brass-dk); }
.chapter-nav__dir {
  font-size: .68rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .14em; color: var(--brass-dk);
}
.chapter-nav a.next { text-align: right; }

/* ---- DISCLAIMER ---- */
.disclaimer {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.25rem; margin: 2.5rem 0 0;
  font-family: var(--font-ui); font-size: .78rem; color: var(--gray); line-height: 1.55;
}

/* ---- HOMEPAGE ---- */
.home-hero {
  background: linear-gradient(170deg, var(--forest) 0%, var(--forest-2) 100%);
  color: var(--ivory); padding: 5rem 1.5rem 4.2rem; text-align: center;
}
.home-hero h1 {
  font-size: clamp(2rem, 5vw, 3.3rem); font-weight: 700; line-height: 1.1;
  margin-bottom: 1.2rem; max-width: 760px; margin-left: auto; margin-right: auto;
  letter-spacing: -.012em;
}
.home-hero h1 em { font-style: italic; color: var(--brass); }
.home-hero__sub {
  font-family: var(--font-ui); font-size: 1.05rem; color: #CBD8D0;
  max-width: 560px; margin: 0 auto 2.2rem; line-height: 1.7;
}
.btn {
  display: inline-block; font-family: var(--font-ui); font-size: .9rem; font-weight: 700;
  padding: .85rem 1.85rem; border-radius: 4px; text-decoration: none; cursor: pointer;
  transition: opacity .15s, transform .12s;
}
.btn:hover { opacity: .92; transform: translateY(-1px); }
.btn--primary { background: var(--brass); color: var(--forest-2); }
.btn--ghost   { background: transparent; color: var(--ivory); border: 1.5px solid rgba(250,247,240,.4); margin-left: .8rem; }

.home-section { max-width: var(--wide-w); margin: 0 auto; padding: 3.5rem 1.5rem; }
.home-section__title {
  font-family: var(--font-body); font-size: 1.7rem; font-weight: 700;
  color: var(--forest); margin-bottom: .4rem;
}
.home-section__sub { color: var(--gray); font-family: var(--font-ui); font-size: .95rem; margin-bottom: 2.3rem; }

.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.3rem; }
.chapter-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.45rem 1.55rem 1.3rem; text-decoration: none; color: inherit;
  transition: transform .14s, box-shadow .14s; display: block;
}
.chapter-card:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(13,59,46,.12); }
.chapter-card__num {
  font-family: var(--font-ui); font-size: .68rem; font-weight: 800;
  letter-spacing: .16em; text-transform: uppercase; color: var(--brass-dk); margin-bottom: .45rem;
}
.chapter-card__title {
  font-family: var(--font-body); font-size: 1.05rem; font-weight: 700;
  color: var(--forest); line-height: 1.32; margin-bottom: .45rem;
}
.chapter-card__desc { font-family: var(--font-ui); font-size: .82rem; color: var(--gray); line-height: 1.55; }

/* ---- SITE FOOTER ---- */
.site-footer {
  background: var(--forest-2); color: #9AAFA3;
  font-family: var(--font-ui); font-size: .82rem; padding: 2.2rem 1.5rem; margin-top: 4rem;
  border-top: 3px solid var(--brass);
}
.site-footer__inner {
  max-width: var(--wide-w); margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem;
}
.site-footer a { color: var(--brass); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ---- UTILITY ---- */
.divider { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.text-center { text-align: center; }

.nav-toggle {
  display: none; background: none; border: none; color: var(--ivory);
  font-size: 1.5rem; cursor: pointer; padding: .3rem .5rem;
}

@media (max-width: 640px) {
  .nav-toggle { display: block; }
  .site-nav {
    display: none; position: absolute; top: 62px; left: 0; right: 0;
    background: var(--forest-2); flex-direction: column; gap: 0;
    border-bottom: 2px solid var(--brass); z-index: 50;
  }
  .site-nav--open { display: flex; }
  .site-nav a { padding: 1rem 1.5rem; border-bottom: 1px solid rgba(250,247,240,.08); }
  .site-header { position: relative; }
  .chapter-nav { flex-direction: column; }
  .chapter-nav a.next { text-align: left; }
  .home-hero { padding: 3rem 1rem 2.6rem; }
}

/* ---- MOBILE TABLE OVERFLOW ---- */
@media (max-width: 640px) {
  .code-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  .code-table td, .code-table th { white-space: normal; min-width: 110px; }
}

/* ---- PRINT (physicians will print these guides) ---- */
@media print {
  .site-header, .site-footer, .chapter-nav, .nav-toggle, form { display: none !important; }
  .article-hero { background: none !important; color: #000 !important; padding: 0 0 1rem; }
  .article-hero h1, .article-hero__eyebrow, .article-hero__sub { color: #000 !important; }
  .dollar-impact { background: none !important; color: #000 !important; border: 2px solid #000; }
  .dollar-impact__num, .dollar-impact__label { color: #000 !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  a { color: #000; text-decoration: none; }
  .article-body a::after { content: ""; }
}

/* ---- ACCESSIBILITY: visible keyboard focus ---- */
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid var(--brass); outline-offset: 2px;
}

/* ---- CONTACT FORM ---- */
.contact-form { max-width: 560px; margin: 1.5rem 0; display: flex; flex-direction: column; }
.contact-form label { font-family: var(--font-ui); font-weight: 600; color: var(--forest); margin: 1rem 0 .35rem; font-size: .95rem; }
.contact-form .muted { font-weight: 400; color: var(--gray); }
.contact-form input, .contact-form textarea {
  font-family: var(--font-ui); font-size: 1rem; padding: .7rem .85rem;
  border: 1.5px solid var(--border); border-radius: 6px; background: #fff; color: var(--ink);
}
.contact-form input:focus, .contact-form textarea:focus { outline: 3px solid var(--brass); outline-offset: 1px; border-color: var(--brass-dk); }
.contact-form .btn-primary, .btn-primary {
  margin-top: 1.4rem; align-self: flex-start; cursor: pointer;
  background: var(--brass-dk); color: #fff; border: none; border-radius: 6px;
  font-family: var(--font-ui); font-weight: 600; font-size: 1rem; padding: .8rem 1.6rem;
}
.contact-form .btn-primary:hover, .btn-primary:hover { background: var(--forest); }
.hidden-field { position: absolute; left: -9999px; }
p.muted { color: var(--gray); font-family: var(--font-ui); font-size: .9rem; }

/* ---- GLOSSARY PAGE ---- */
.glossary { margin: 0; }
.glossary-entry { padding: 1.35rem 0; border-bottom: 1px solid var(--border); }
.glossary-entry:first-child { padding-top: 0; }
.glossary-entry dt { font-family: var(--font-ui); font-weight: 700; color: var(--forest); font-size: 1.15rem; margin: 0 0 .45rem; letter-spacing: .01em; }
.glossary-entry dd { margin: 0; color: var(--slate); line-height: 1.65; font-size: 1.02rem; max-width: 62ch; }

/* ---- HOVERABLE GLOSSARY TERMS (in-text) ---- */
.gloss {
  position: relative; cursor: pointer; white-space: nowrap;
}
.gloss-term {
  color: var(--brass-dk); border-bottom: 1.5px dotted var(--brass-dk); font-weight: 600;
}
.gloss:hover .gloss-term, .gloss:focus .gloss-term, .gloss.gloss--open .gloss-term { color: var(--forest); border-bottom-color: var(--forest); }
.gloss .gloss-pop {
  visibility: hidden; opacity: 0; transition: opacity .15s;
  position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%);
  width: 280px; max-width: min(280px, 86vw); white-space: normal;
  background: var(--forest); color: #fff;
  font-family: var(--font-ui); font-size: .82rem; font-weight: 400; line-height: 1.5;
  padding: .65rem .8rem; border-radius: 6px; z-index: 60; box-shadow: 0 6px 18px rgba(0,0,0,.28);
  text-align: left; pointer-events: none;
}
.gloss .gloss-pop::after {
  content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--forest);
}
.gloss:hover .gloss-pop, .gloss:focus .gloss-pop, .gloss.gloss--open .gloss-pop { visibility: visible; opacity: 1; }
@media (max-width: 640px) {
  .gloss .gloss-pop { width: 220px; max-width: 86vw; }
} }

/* ---- TEMPLATES PAGE ---- */
.tmpl-list { display: flex; flex-direction: column; gap: 1.25rem; margin-top: 1rem; }
.tmpl-card { border: 1.5px solid var(--border); border-radius: 8px; overflow: hidden; }
.tmpl-card__head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; background: var(--key-bg); padding: .7rem 1rem; border-bottom: 1.5px solid var(--border); }
.tmpl-card__head h3 { margin: 0; font-family: var(--font-ui); font-size: 1rem; color: var(--forest); }
.tmpl-copy { cursor: pointer; background: var(--brass-dk); color: #fff; border: none; border-radius: 5px; font-family: var(--font-ui); font-weight: 600; font-size: .82rem; padding: .4rem .9rem; white-space: nowrap; }
.tmpl-copy:hover { background: var(--forest); }
.tmpl-copy.copied { background: #2E7D32; }
.tmpl-text { margin: 0; padding: 1rem; font-family: var(--font-mono, monospace); font-size: .9rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; background: #fff; color: var(--ink); }
.tmpl-card { max-width: 100%; }

/* ---- HERO CTA BUTTON ROW ---- */
.hero-cta { display: flex; flex-wrap: wrap; gap: 0.9rem; justify-content: center; align-items: center; margin-top: 1.75rem; }
.hero-cta .btn { margin: 0; }

/* ---- SOURCES LIST ---- */
.sources-list { font-size: .95rem; line-height: 1.6; }
.sources-list a { color: var(--brass-dk); text-decoration: underline; word-break: break-word; }
.sources-list a:hover { color: var(--forest); }

/* Glossary terms inside headings inherit the heading color */
.article-body h2 .gloss-term, .article-body h3 .gloss-term { color: inherit; border-bottom-color: currentColor; font-weight: inherit; }

/* Template note: guidance shown below the copyable block, not included when copied */
.tmpl-note { margin: .5rem 0 0; padding: .55rem .75rem; font-family: var(--font-ui); font-size: .85rem; line-height: 1.5; color: var(--slate); background: var(--key-bg, #EFF5F0); border-left: 3px solid var(--brass); border-radius: 0 4px 4px 0; }
.tmpl-note strong { color: var(--forest); }

/* Side-by-side note comparison (Guide 4) */
.notes-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.75rem 0; }
@media (max-width: 720px) { .notes-compare { grid-template-columns: 1fr; } }
.note-col { border: 1px solid var(--rule, #DAD3C4); border-radius: 8px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.note-col__head { padding: .6rem .85rem; font-family: var(--font-ui); color: #fff; display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.note-col__name { font-weight: 600; font-size: .95rem; }
.note-col__code { font-weight: 600; font-size: .8rem; opacity: .95; white-space: nowrap; }
.note-col--lose .note-col__head { background: #8C2F2A; }
.note-col--win .note-col__head { background: var(--forest, #0D3B2E); }
.note-col__body { padding: .55rem .9rem .25rem; }
.note-col__body p { font-size: .85rem; line-height: 1.5; margin: .35rem 0 .65rem; }
.note-col__body strong { color: var(--brass, #9A7B16); font-weight: 700; }
.note-col--win .note-col__body strong { color: var(--forest, #0D3B2E); }
