/* Statutory edition of phyee.com (/ordinance/). Generated markup: tools/home.py.
   Set like a bilingual Hong Kong ordinance: parallel English / Chinese columns, marginal notes,
   an interpretation clause, schedules on coloured form paper, an amendment history that grows. */

:root {
  --paper: #FCFBF7;
  --ink: #141414;
  --ink-2: #555049;
  --rule: #141414;
  --seal: #D22A1F;
  --pencil: #2B54C7;
  --form-green: #D7E8D3;
  --form-pink: #F6D3CD;
  --en: "Spectral", "Iowan Old Style", Georgia, serif;
  --zh: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --gutter: clamp(16px, 4vw, 64px);
  --mn: 190px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--en); font-size: 19px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
[lang="zh-Hans"] { font-family: var(--zh); }
a { color: inherit; text-decoration-color: var(--seal); text-decoration-thickness: 1.5px; text-underline-offset: .18em; }
a:hover { color: var(--seal); }
::selection { background: var(--seal); color: var(--paper); }
:focus-visible { outline: 2px solid var(--seal); outline-offset: 3px; }
img { max-width: 100%; height: auto; display: block; }

/* Language view: the parallel text is the bilingual site. */
body[data-view="en"] .zh { display: none !important; }
body[data-view="zh"] .en { display: none !important; }

/* ---------- bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 20; background: var(--paper);
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px var(--gutter); border-bottom: 1px solid var(--rule);
  font-size: 14px;
}
.cap { margin: 0; display: flex; gap: 18px; align-items: baseline; }
.cap b { font-weight: 800; letter-spacing: .02em; }
.cap span { color: var(--ink-2); }
.tools { display: flex; align-items: center; gap: 10px 18px; flex-wrap: wrap; }
.cf { display: inline-flex; gap: .35em; align-items: baseline; text-decoration: none; padding: 5px 2px; border-bottom: 1.5px solid var(--seal); }
.cf i { color: var(--seal); }
.cf:hover { color: var(--seal); }
body[data-view="both"] .cf .zh::before { content: "· "; color: var(--ink-2); }
.view { display: inline-flex; border: 1px solid var(--rule); }
.view button { appearance: none; border: 0; background: none; font: inherit; font-size: 14px; padding: 6px 14px; cursor: pointer; color: var(--ink); }
.view button + button { border-left: 1px solid var(--rule); }
.view button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.view button:hover:not([aria-pressed="true"]) { background: #EEE9DF; }

main { max-width: 1320px; margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- title ---------- */
.title { display: grid; grid-template-columns: 1fr auto; gap: 40px; align-items: start; padding: clamp(48px, 8vw, 120px) 0 clamp(40px, 5vw, 72px); border-bottom: 3px double var(--rule); }
.title h1 { margin: 0; font-weight: 800; line-height: .92; letter-spacing: -0.035em; }
.title h1 .en { display: block; font-size: clamp(60px, 9vw, 136px); }
.title h1 .en i { font-style: normal; font-weight: 400; letter-spacing: -0.03em; }
.title h1 .zh { display: block; font-weight: 900; font-size: clamp(44px, 6.4vw, 96px); letter-spacing: 0.02em; margin-top: .18em; }
.long { margin-top: clamp(24px, 3vw, 40px); display: grid; grid-template-columns: 1fr 1fr; gap: 32px; max-width: 980px; }
body:not([data-view="both"]) .long { grid-template-columns: 1fr; max-width: 640px; }
.long p { margin: 0; font-size: clamp(18px, 1.5vw, 21px); line-height: 1.5; }
.long .en { font-style: italic; }
.commence { margin: 22px 0 0; color: var(--ink-2); font-size: 15px; display: flex; gap: 24px; }
.seal { width: clamp(120px, 15vw, 220px); height: auto; transform: rotate(-7deg); margin-top: 8px; mix-blend-mode: multiply; }
@media (prefers-reduced-motion: no-preference) {
  .seal { animation: stamp .5s cubic-bezier(.2,.9,.3,1) .35s both; }
  @keyframes stamp { from { transform: rotate(-7deg) scale(1.6); opacity: 0; } 60% { opacity: 1; } to { transform: rotate(-7deg) scale(1); opacity: 1; } }
}

/* ---------- arrangement of sections ---------- */
.contents { padding: 28px 0 8px; border-bottom: 1px solid var(--rule); }
.part-label { margin: 0 0 12px; font-size: 13px; letter-spacing: .16em; text-transform: uppercase; font-weight: 700; display: flex; gap: 18px; }
.contents ol { list-style: none; margin: 0; padding: 0; columns: 3 260px; column-gap: 40px; }
.contents li { break-inside: avoid; padding: 6px 0; border-top: 1px solid #DDD6C9; display: flex; gap: 12px; align-items: baseline; font-size: 16px; }
.contents li a { min-width: 3.6em; font-weight: 700; text-decoration: none; color: var(--seal); }
.contents li .zh { color: var(--ink-2); }
body[data-view="both"] .contents li .zh::before { content: "·"; margin-right: 8px; color: #B9B0A2; }

/* ---------- parts and sections ---------- */
.part { text-align: center; font-weight: 400; font-size: 15px; letter-spacing: .18em; text-transform: uppercase; margin: clamp(56px, 7vw, 96px) 0 28px; display: flex; flex-direction: column; gap: 4px; }
.part b { display: block; font-size: clamp(24px, 2.4vw, 32px); letter-spacing: .04em; text-transform: none; font-weight: 700; margin-top: 4px; }
.part .zh b { letter-spacing: .2em; }

.s {
  position: relative;
  display: grid; grid-template-columns: var(--mn) minmax(0, 1fr) minmax(0, 1fr); gap: 0 clamp(24px, 3vw, 48px);
  padding: 22px 0 26px; border-top: 1px solid #DDD6C9;
}
body:not([data-view="both"]) .s { grid-template-columns: var(--mn) minmax(0, 760px); }
.s > .en, .s > .zh { grid-row: 1; position: relative; }
.s p { margin: 0 0 .55em; }
.s .sub { padding-left: 2.1em; position: relative; }
.s .n { font-weight: 800; margin-right: .35em; }
.s .zh p { line-height: 1.85; }
.s .zh .n { font-family: var(--en); }

/* Marginal notes, the way older ordinances set them. */
.mn { grid-row: 1 / span 2; margin: 0; padding-top: 4px; font-size: 14px; line-height: 1.35; font-weight: 700; border-top: 3px solid var(--seal); padding-right: 8px; align-self: start; }
.mn span { display: block; }
.mn .zh { font-weight: 700; color: var(--ink-2); margin-top: 2px; }
.mn .status { margin-top: 10px; font-weight: 400; font-style: italic; color: var(--seal); font-family: var(--en); }
.mn .status.zh { margin-top: 2px; font-family: var(--zh); font-style: normal; color: var(--seal); }
body[data-view="zh"] .mn .status.zh { margin-top: 10px; }

.defs { margin: .2em 0 0 2.1em; }
.defs dt { display: inline; font-weight: 700; font-style: italic; }
.defs .zh dt, .zh .defs dt { font-style: normal; }
.defs dt::before { content: "“"; } .defs dt::after { content: "”"; }
.zh .defs dt::before { content: "「"; } .zh .defs dt::after { content: "」"; }
.defs dd { display: inline; margin: 0 0 0 .3em; }
.defs dd::after { content: ""; display: block; margin-bottom: .55em; }

/* Pencil annotation, drawn in as you reach it. */
.pencil { position: absolute; pointer-events: none; overflow: visible; }
.pencil path { fill: none; stroke: var(--pencil); stroke-width: 2.2; stroke-linecap: round; opacity: .85; }
.pencil.circle { left: 1.2em; top: -0.45em; width: calc(100% - 0.6em); height: calc(100% + 0.9em); }
.note-pencil { position: absolute; color: var(--pencil); font-style: italic; font-size: 17px; transform: rotate(-4deg); right: 0; bottom: -1.5em; margin: 0; }
@media (prefers-reduced-motion: no-preference) {
  .js .pencil path { stroke-dasharray: 800; stroke-dashoffset: 800; transition: stroke-dashoffset 1.4s cubic-bezier(.4,.1,.2,1); }
  .js .pencil.drawn path { stroke-dashoffset: 0; }
  .js .note-pencil { opacity: 0; transition: opacity .6s 1.1s; }
  .js .s.inked .note-pencil { opacity: 1; }
}

.work .fig { grid-column: 2 / -1; margin: 18px 0 0; display: grid; grid-template-columns: minmax(0, 360px) 1fr; gap: 24px; align-items: end; }
.fig img { width: 100%; border: 1px solid var(--rule); background: #fff; padding: 18px; }
.fig figcaption { font-size: 14px; color: var(--ink-2); display: flex; flex-direction: column; gap: 4px; }

/* ---------- schedules on coloured form paper ---------- */
.schedule {
  margin: clamp(64px, 8vw, 112px) calc(50% - 50vw) 0; padding: clamp(36px, 5vw, 64px) calc(50vw - 50%);
  background: var(--form-green); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  display: grid; grid-template-columns: var(--mn) minmax(0, 1fr); gap: 0 clamp(24px, 3vw, 48px);
}
.schedule.two { background: var(--form-pink); margin-top: 0; border-top: 0; }
.sch-head h2 { margin: 0; font-size: 15px; letter-spacing: .16em; text-transform: uppercase; display: flex; flex-direction: column; gap: 2px; }
.sch-head p { margin: 8px 0 0; font-weight: 700; font-size: 20px; line-height: 1.25; display: flex; flex-direction: column; gap: 4px; }
.sch-head .ref { font-weight: 400; font-size: 14px; color: var(--ink-2); }
.items { width: 100%; max-width: 820px; border-collapse: collapse; font-size: clamp(20px, 2vw, 26px); }
.items th { text-align: left; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; padding: 0 0 10px; border-bottom: 2px solid var(--rule); }
.items td { padding: 10px 0; border-bottom: 1px solid rgba(20,20,20,.25); vertical-align: baseline; }
.items td:first-child { width: 3.4em; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.items td.zh { color: var(--ink); }
body[data-view="both"] .items td.en { width: 50%; }
.letter p { margin: 0 0 12px; font-size: clamp(19px, 1.7vw, 22px); max-width: 38em; }
.letter .mail { display: inline-block; margin-top: 10px; font-size: clamp(24px, 3.4vw, 46px); font-weight: 700; letter-spacing: -0.02em; word-break: break-all; text-decoration-thickness: 3px; }

/* ---------- amendment history ---------- */
.history { padding: clamp(48px, 6vw, 80px) 0 clamp(64px, 8vw, 110px); display: grid; grid-template-columns: var(--mn) minmax(0, 1fr); gap: 0 clamp(24px, 3vw, 48px); }
.history h2 { margin: 0; font-size: 14px; letter-spacing: .14em; text-transform: uppercase; display: flex; flex-direction: column; gap: 2px; border-top: 3px solid var(--seal); padding-top: 6px; align-self: start; }
.history ol { list-style: none; margin: 0; padding: 0; }
.history li { display: grid; grid-template-columns: 5em 1fr; gap: 6px 16px; padding: 8px 0; border-top: 1px solid #DDD6C9; font-size: 16px; }
.history li .zh { grid-column: 2; color: var(--ink-2); }
.history time { font-weight: 700; font-variant-numeric: tabular-nums; }
.disclaimer { grid-column: 2; margin: 28px 0 0; font-size: 14px; color: var(--ink-2); display: flex; flex-direction: column; gap: 4px; }

/* ---------- phones ---------- */
@media (max-width: 860px) {
  :root { --mn: 1fr; }
  body { font-size: 17px; }
  /* The seal takes the corner beside the short title in every view; the long title runs full width below. */
  .title { grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; padding-top: 32px; }
  .names { display: contents; }
  .title h1 { grid-column: 1; grid-row: 1; align-self: start; }
  .seal { grid-column: 2; grid-row: 1; width: 84px; margin: 4px 4px 0 0; }
  .long, .commence { grid-column: 1 / -1; }
  .title h1 .en { font-size: clamp(48px, 14vw, 72px); }
  .long, body:not([data-view="both"]) .long { grid-template-columns: 1fr; gap: 14px; }
  .s, body:not([data-view="both"]) .s { grid-template-columns: 1fr; gap: 10px; padding: 18px 0 22px; }
  .s > .en, .s > .zh { grid-row: auto; }
  .mn { grid-row: auto; display: flex; flex-wrap: wrap; gap: 4px 12px; border-top-width: 2px; }
  .mn .status { flex-basis: 100%; margin-top: 2px; }
  body[data-view="both"] .s > .zh { padding-top: 10px; border-top: 1px dashed #CFC6B6; }
  .work .fig { grid-column: auto; grid-template-columns: 1fr; }
  .schedule, .history { grid-template-columns: 1fr; gap: 18px; }
  .disclaimer { grid-column: auto; }
  .bar { padding: 10px var(--gutter); }
  .cap span { display: none; }
  body[data-view="both"] .cf .zh { display: none; }
  /* Two rows on phones: the chapter and the cross-reference, then the language views. */
  .bar { gap: 8px 12px; }
  .tools { display: contents; }
  .cf { margin-left: auto; padding: 2px 0; }
  .view { flex-basis: 100%; }
  .view button { flex: 1; }
  .view button { padding: 6px 10px; font-size: 13px; }
  .pencil.circle { left: 1.3em; width: calc(100% - 1.5em); }
  .note-pencil { position: static; margin-top: 4px; text-align: right; }
}
