/* WhatIsHIPPA.com, dictionary-entry meets proofreader's red pen.
   Tokens: paper / ink / correction red / correction green / federal blue. Light + dark. */

:root {
  --paper: #fbfbf9;
  --paper-raised: #ffffff;
  --ink: #1c2128;
  --muted: #5a6472;
  --red: #d6392f;
  --red-ink: #b32c24;      /* red that passes contrast on paper for text */
  --red-wash: #fbeae8;
  --green: #2a9d54;        /* the correction color: the fixed spelling */
  --green-ink: #1e7d3e;
  --green-wash: #e6f4ea;
  --blue: #2f5fa3;
  --line: #e4e4dd;
  --shadow: 0 1px 2px rgba(28, 33, 40, 0.06), 0 8px 24px rgba(28, 33, 40, 0.05);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --measure: 42rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14171c;
    --paper-raised: #1c2129;
    --ink: #e9eae5;
    --muted: #9aa3ae;
    --red: #ff6f61;
    --red-ink: #ff8177;
    --red-wash: #32211f;
    --green: #4fb872;
    --green-ink: #6ecb8a;
    --green-wash: #1d3225;
    --blue: #85aae0;
    --line: #2a2f37;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme="dark"] {
  --paper: #14171c;
  --paper-raised: #1c2129;
  --ink: #e9eae5;
  --muted: #9aa3ae;
  --red: #ff6f61;
  --red-ink: #ff8177;
  --red-wash: #32211f;
  --green: #4fb872;
  --green-ink: #6ecb8a;
  --green-wash: #1d3225;
  --blue: #85aae0;
  --line: #2a2f37;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 48rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

a { color: var(--blue); }
a:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 3px; }

strong { font-weight: 700; }

.skip-link {
  position: absolute;
  left: 1rem; top: -3rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.5rem 1rem;
  border-radius: 0 0 6px 6px;
  text-decoration: none;
  transition: top 120ms ease;
  z-index: 10;
}
.skip-link:focus { top: 0; }

/* red spell-check squiggle under every intentional misspelling */
.sic {
  text-decoration: underline wavy var(--red);
  text-decoration-thickness: 0.07em;
  text-underline-offset: 0.18em;
  white-space: nowrap;
}

/* ---------- Hero: the torn-out dictionary page ---------- */

.hero {
  padding: clamp(3.5rem, 10vh, 6.5rem) 0 1rem;
}

.eyebrow {
  margin: 0 0 1.5rem;
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* negative margins cancel the card's padding so the entry text
   lines up with the body text in the sections below */
.torn-page {
  margin: 2rem -2.4rem 0.5rem -2.9rem;
  transform: rotate(-0.7deg);
  filter: drop-shadow(0 1px 2px rgba(15, 18, 22, 0.14))
          drop-shadow(0 16px 30px rgba(15, 18, 22, 0.13));
}

/* jagged left edge: the side torn from the binding */
.torn-page-inner {
  background: var(--paper-raised);
  padding: 2.4rem 2.4rem 2.6rem 2.9rem;
  clip-path: polygon(
    1.2% 0, 100% 0, 100% 100%, 1.8% 100%,
    0.3% 95%, 1.5% 89%, 0.2% 83%, 1.4% 77%, 0.5% 71%, 1.7% 65%,
    0.3% 59%, 1.3% 53%, 0.6% 47%, 1.6% 41%, 0.2% 35%, 1.5% 29%,
    0.4% 23%, 1.7% 17%, 0.3% 11%, 1.4% 5%
  );
}

.headword {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(3rem, 11vw, 5.4rem);
  line-height: 1.05;
  letter-spacing: 0.01em;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.35em;
  user-select: none;
}

.word { position: relative; }

/* The correction, in two beats: the red pen crosses out the whole
   misspelled word, then writes the right one next to it in green. */
.wrong { animation: fade-wrong 300ms ease 720ms forwards; }

.strike {
  position: absolute;
  left: -2%;
  top: 52%;
  width: 104%;
  height: 0.05em;
  background: var(--red);
  border-radius: 999px;
  transform: rotate(-5deg) scaleX(0);
  transform-origin: left center;
  animation: strike-in 340ms ease-out 700ms forwards;
}

.right {
  color: var(--green-ink);
  opacity: 0;
  transform: translateX(-0.2em) scale(0.85);
  animation: write-in 420ms cubic-bezier(0.2, 0.7, 0.3, 1.15) 1200ms forwards;
}

@keyframes fade-wrong { to { color: var(--muted); } }
@keyframes strike-in { to { transform: rotate(-5deg) scaleX(1); } }
@keyframes write-in { to { opacity: 1; transform: translateX(0) scale(1); } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .wrong { animation: none; color: var(--muted); }
  .strike { animation: none; transform: rotate(-5deg) scaleX(1); }
  .right { animation: none; opacity: 1; transform: none; }
}

.pronunciation {
  margin: 1.75rem 0 0.75rem;
  color: var(--muted);
  font-size: 1rem;
}

.tag-misspelling {
  display: inline-block;
  background: var(--red-wash);
  color: var(--red-ink);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  vertical-align: 0.1em;
}

.definition {
  margin: 0;
  padding-left: 1.25rem;
  max-width: 40rem;
}
.definition li { margin-bottom: 0.5rem; }

/* cross-reference links: only the HIPPA part carries the squiggle */
.see {
  color: var(--blue);
  font-weight: 500;
  text-decoration: none;
}
.see:hover { text-decoration: underline; }

/* ---------- Sections ---------- */

.section {
  padding: 3.25rem 0;
  border-bottom: 1px solid var(--line);
}
.section:last-of-type { border-bottom: none; }

.section h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.5rem, 4vw, 2rem);
  line-height: 1.2;
  margin: 0 0 1.25rem;
  text-wrap: balance;
}
.section h2 strong { color: var(--green-ink); }

.section p, .section ul { max-width: var(--measure); }

/* ---------- Acronym letter blocks ---------- */

.acronym { margin: 2.5rem 0 0; }

.acronym-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem;
}

.acronym-letter {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start; /* letters share one baseline across squares */
  gap: 0.45rem;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0.9rem 0.5rem 0.5rem;
  width: 6.4rem;
  height: 6.4rem;
  text-align: center;
}

.acronym-letter b {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 2rem;
  line-height: 1;
}
.acronym-letter:nth-child(3) b { color: var(--green-ink); } /* the lone, correct P */

.acronym-letter span {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  max-width: 100%;
  hyphens: manual; /* break only at the &shy; in Account­ability */
}

.acronym-and {
  align-self: center;
  font-family: var(--font-display);
  font-style: italic;
  color: var(--muted);
  padding: 0 0.1rem;
}

.acronym figcaption {
  margin-top: 1rem;
  font-size: 0.9375rem;
  color: var(--muted);
  max-width: 40rem;
}

/* ---------- FAQ ---------- */

.faq-sub {
  display: block;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--muted);
  margin-top: 0.35rem;
}

.faq-item { border-bottom: 1px solid var(--line); }
.faq-item:first-of-type { border-top: 1px solid var(--line); margin-top: 2rem; }

.faq-item summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 0.25rem;
}
.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary h3 {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.4;
}

.faq-item summary::after {
  content: "+";
  flex: none;
  font-family: var(--font-display);
  font-size: 1.4rem;
  line-height: 1;
  color: var(--red-ink);
  transition: transform 160ms ease;
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item summary:hover h3 { color: var(--red-ink); }
.faq-item summary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

.faq-answer { padding: 0 0.25rem 1.4rem; }
.faq-answer > p { margin: 0 0 0.75rem; max-width: var(--measure); }
.faq-answer > p:last-child { margin-bottom: 0; }

/* the correct spelling, underlined in green: the opposite of the red squiggle */
.fix {
  text-decoration: underline solid var(--green);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

/* the "read more at HHS" line that closes each answer */
.readmore {
  font-size: 0.9375rem;
  color: var(--muted);
}

/* ---------- Official sources ---------- */

.sources ul {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  max-width: var(--measure);
}
.sources li {
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
}
.sources li:last-child { border-bottom: 1px solid var(--line); }
.sources a { font-weight: 700; text-decoration: none; }
.sources a:hover { text-decoration: underline; }
.sources li span { display: block; font-size: 0.9375rem; color: var(--muted); }

/* ---------- Share ---------- */

.copy-link {
  margin-top: 0.75rem;
  font: inherit;
  font-weight: 700;
  color: var(--paper);
  background: var(--ink);
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.4rem;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}
.copy-link:hover { opacity: 0.88; }
.copy-link:active { transform: scale(0.98); }
.copy-link:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.copy-link.copied { background: var(--green-ink); color: var(--paper); }

.hippa-count {
  margin-top: 1.25rem;
  font-size: 0.9375rem;
  color: var(--muted);
  font-style: italic;
}

/* ---------- Footer ---------- */

.footer {
  max-width: 48rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3.5rem;
  font-size: 0.9375rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.footer p { max-width: var(--measure); }
.footer-fine { font-size: 0.8125rem; }

/* the crossed-out HIPPA in the footer */
.xed {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--red);
  text-decoration-thickness: 0.09em;
}

/* ---------- Small screens ---------- */

@media (max-width: 540px) {
  .torn-page { margin-left: -1.25rem; margin-right: -1.25rem; }
  .torn-page-inner { padding: 1.7rem 1.25rem 1.9rem 1.7rem; }
}

@media (max-width: 480px) {
  .acronym-letter { width: 5.3rem; height: 5.3rem; }
  .acronym-letter b { font-size: 1.6rem; }
  .acronym-letter span { font-size: 0.6rem; }
}
