/* WP1: the 기안문 (별지 제1호서식) under one light, the plan slip, the seal.
   Proportions are measured from Hancom's own preview of the blank form (A4, 210 x 297):
   every length on the sheet is in --u, 1% of the sheet's width (a container query unit).
   Paper stays paper in dark mode, so the sheet and the slip pin their own light-mode inks. */

/* --sx-off: the room left of the sheet for the slip; a length, not a percentage, so every box reads the same value */
.sx { --sx-off: 150px; position: relative; }
@media (max-width: 1199px) { .sx { --sx-off: 120px; } }
.sx-frame { container-type: inline-size; }
.sx-plane {
  --lx: .94; --ly: .34; --rk: 1; --amp: 1;   /* no JS: raking light from the upper left */
  position: relative;
}
.js .sx-hero .sx-plane { --rk: 0; }        /* with JS the light starts in front and swings */
@media (prefers-reduced-motion: reduce) { .js .sx-hero .sx-plane { --rk: 1; } }

/* ---------- the sheet */
.sheet {
  --u: 1cqw;
  --ink: #17181b; --ink-2: #5d5e63; --pencil: #2f55c8; --flag: #9a5b13; --seal: #c8281e;
  --form-red: #d0362b; --form-bar: #c3c3c3;
  position: relative; display: flex; flex-direction: column;
  aspect-ratio: 210 / 297;
  padding: calc(var(--u) * 9.6) calc(var(--u) * 14.6) calc(var(--u) * 15) calc(var(--u) * 9.7);
  background: var(--sheet); color: var(--ink);
  font: 400 calc(var(--u) * 2.1) / 1.4 var(--font-sheet);
  word-break: keep-all; overflow-wrap: anywhere; line-height: 1.4;
  border-radius: 1px;
  box-shadow: 0 1px 1px rgb(23 24 27 / .05), 0 calc(var(--u) * 5) calc(var(--u) * 9) calc(var(--u) * -4) rgb(23 24 27 / .3);
  -webkit-user-select: text; user-select: text;
}
:root[data-theme="dark"] .sheet { box-shadow: 0 1px 1px rgb(0 0 0 / .4), 0 calc(var(--u) * 5) calc(var(--u) * 10) calc(var(--u) * -3) rgb(0 0 0 / .7); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sheet { box-shadow: 0 1px 1px rgb(0 0 0 / .4), 0 calc(var(--u) * 5) calc(var(--u) * 10) calc(var(--u) * -3) rgb(0 0 0 / .7); }
}
.sheet p { margin: 0; }
/* The plan's 23 routine ops stay in ink: their relief is the only mark, and it shows when the light rakes.
   Blue is kept for the one edit that guard flags, so the eye lands there first. */
.sheet ins, .sheet del { color: inherit; text-decoration: none; transition: color var(--t3) var(--ease), opacity var(--t3) var(--ease); }
.sheet del { color: var(--ink-2); text-decoration: line-through; text-decoration-thickness: 1px; text-decoration-color: rgb(23 24 27 / .32); }
.sheet .gm-edit ins, .sheet .gm-edit del { color: var(--pencil); }
.sheet .gm-edit del { text-decoration-color: color-mix(in srgb, var(--pencil) 80%, transparent); }
/* the flagged date on its amber wash: 6.50:1 on light paper, 5.37:1 on dark-mode paper (#2f55c8 was 5.19 / 4.29);
   the approved-state rule below (.sx[data-state^="approved"] .sheet ins) is more specific and returns it to ink */
.sheet .is-flag .gm-flag { color: #2448ac; }
.sheet ::selection { background: rgb(47 85 200 / .2); }

.gm-cap { font-size: calc(var(--u) * 1.36); letter-spacing: -.01em; white-space: nowrap; }
.gm-org {
  margin-top: calc(var(--u) * 4.4) !important; text-align: center;
  font-size: calc(var(--u) * 2.75); font-weight: 700; letter-spacing: .42em; text-indent: .42em;
}
.gm-head { margin-top: calc(var(--u) * 2.9); line-height: 1.4; }
.gm-rule { border: 0; border-top: 1px solid var(--ink); margin: calc(var(--u) * 1.6) 0 0; height: 0; }
.gm-body { flex: 1 0 auto; padding-top: calc(var(--u) * 2.4); line-height: 1.62; }
.gm-body p { white-space: pre-wrap; }
.gm-body .gm-sp { height: 1.62em; }
.gm-fill { display: block; }
.gm-edit { white-space: nowrap; }
.gm-from {
  position: relative; align-self: center; margin-top: calc(var(--u) * 1.5) !important;
  font-size: calc(var(--u) * 2.75); font-weight: 700; letter-spacing: .4em; line-height: 1;
}
.gm-seal {
  position: absolute; left: calc(100% - .5em); top: 50%;
  width: calc(var(--u) * 8.6); height: calc(var(--u) * 8.3); transform: translateY(-50%);
  display: flex; align-items: center; padding-left: calc(var(--u) * .9);
  border: max(1px, calc(var(--u) * .2)) solid var(--form-red); color: var(--form-red);
  font-size: calc(var(--u) * 1.6); font-weight: 400; letter-spacing: 0; text-indent: 0;
}
.gm-rows {
  width: 100%; margin-top: calc(var(--u) * 10.6); border-collapse: collapse;
  border-top: calc(var(--u) * 1.05) solid var(--form-bar); border-bottom: 1px solid var(--ink);
  font-size: calc(var(--u) * 1.62); line-height: 1;
}
.gm-rows tbody { display: block; padding: calc(var(--u) * .5) 0 calc(var(--u) * .9); }
.gm-rows tr { display: flex; align-items: center; height: calc(var(--u) * 4.17); }
.gm-rows td { display: block; flex: none; padding: 0 .9em 0 0; white-space: pre; min-width: max-content; }
.gm-rows td:last-child { padding-right: 0; }
.gm-ra td:nth-child(1) { width: 34.5%; } .gm-ra td:nth-child(2) { width: 31%; }
.gm-rc td:nth-child(1) { width: 14.3%; } .gm-rc td:nth-child(2) { width: 35.2%; } .gm-rc td:nth-child(3) { width: 13.8%; }
.gm-rd td:nth-child(1) { width: 14.3%; } .gm-rd td:nth-child(2) { width: 41.1%; }
.gm-re td:nth-child(1) { width: 25.7%; } .gm-re td:nth-child(2) { width: 29.7%; } .gm-re td:nth-child(3) { width: 24.6%; }
.gm-size { align-self: flex-end; margin-top: calc(var(--u) * 2.6) !important; font-size: calc(var(--u) * 1.3); line-height: 1; color: var(--ink); }
.gm-bigo { margin-top: calc(var(--u) * 1.6); font-size: calc(var(--u) * 1.62); line-height: 1.55; }
.gm-bigo p + p { padding-left: 1.1em; text-indent: -1.1em; }
.gm-block { display: block; }

/* the 사본 tab: tucked behind the top edge until the change is written to a copy */
.gm-tab {
  position: absolute; z-index: -1; top: 0; right: calc(var(--u) * 11);
  padding: calc(var(--u) * .7) calc(var(--u) * 2.4) calc(var(--u) * .9);
  background: var(--sheet); color: var(--ink); border-radius: 1px 1px 0 0;
  font-size: calc(var(--u) * 1.9); font-weight: 700; letter-spacing: .3em; text-indent: .3em; line-height: 1;
  transform: translateY(0); visibility: hidden;
  transition: transform var(--t2) var(--ease), visibility 0s linear var(--t2);
}
.sx[data-state^="approved"] .gm-tab { transform: translateY(-100%); visibility: visible; transition: transform var(--t2) var(--ease) var(--t2), visibility 0s; }

/* approved: blue turns to ink, deleted guide text leaves the copy */
.sx[data-state^="approved"] .sheet ins { color: var(--ink); }
.sx[data-state^="approved"] .sheet del { opacity: 0; }
.sx[data-state^="approved"] .gm-was { display: none; }   /* the copy reads 27.(금); no hole in the line */
.sx[data-state="original"] .gm-body { min-height: calc(var(--u) * 40); }

/* the guard flag: computed in the browser, never printed by the build */
.gm-flag { text-decoration: underline 1.5px; text-underline-offset: .22em; text-decoration-color: transparent; }
.is-flag .gm-flag { text-decoration-color: var(--flag); text-decoration-thickness: 2px; background: rgb(154 91 19 / .13); transition: background var(--t3) var(--ease); }
[data-guard] { position: relative; }
.is-flag::after {
  content: attr(data-flag); position: absolute; left: 100%; top: .15em; margin-left: calc(var(--u) * 2.2);
  padding: 0 .45em; font: 500 max(10px, calc(var(--u) * 1.5)) / 1.5 var(--font-mono); letter-spacing: .02em;
  color: var(--flag); border: 1px solid currentColor; border-radius: 2px; white-space: nowrap;
}
html[lang="ko"] .is-flag::after { font-family: var(--font-text); font-weight: 600; letter-spacing: 0; }
.sx[data-state^="approved"] .gm-flag { text-decoration-color: transparent; background: none; }
.sx[data-state^="approved"] .is-flag::after { opacity: 0; }

/* ---------- relief drawn in CSS: first paint, no-JS and no-WebGL.
   --lx/--ly point away from the light, --rk is how low it rakes, --amp how far the plan stands up. */
.sheet .rl {
  --s: calc(var(--rk) * var(--amp));
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  border-radius: 1px; padding-block: .06em;
  box-shadow: calc(var(--lx) * var(--s) * 1.1px) calc(var(--ly) * var(--s) * 1.1px + var(--s) * .3px) calc(var(--s) * 1.4px) calc(var(--s) * -.5px) rgb(28 32 44 / calc(var(--s) * .1));
}
.sheet del.rl { box-shadow: inset calc(var(--lx) * var(--s) * .9px) calc(var(--ly) * var(--s) * .9px + var(--s) * .2px) calc(var(--s) * 1.2px) calc(var(--s) * -.3px) rgb(28 32 44 / calc(var(--s) * .1)); }
.sheet .is-flag .gm-flag.rl { box-shadow: calc(var(--lx) * var(--s) * 2px) calc(var(--ly) * var(--s) * 2px + var(--s) * .4px) calc(var(--s) * 2.5px) calc(var(--s) * -.5px) rgb(154 91 19 / calc(var(--s) * .42)); }
.sheet .gm-block.rl, .sheet .gm-fill { box-shadow: none; }
.gl .sheet .rl { box-shadow: none !important; }

/* the WebGL light: lighting only, multiplied onto the paper */
.sx-gl { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; mix-blend-mode: multiply; opacity: 0; }
.gl .sx-gl { opacity: 1; }

/* ---------- the hero stage */
.sx-hero { touch-action: pan-y; }
.sx-top { position: relative; display: flex; align-items: center; justify-content: flex-end; gap: 16px; min-height: 72px; margin: 0 0 20px var(--sx-off); }
/* the lamp's rod on the page axis: .c-r content starts --axis-gap right of the axis, the sheet --sx-off further */
.sx-lamp {
  position: absolute; top: 0; left: calc(var(--sx-off) * -1 - var(--axis-gap) + .5px);
  width: 72px; height: 72px; transform: translateX(-50%); border-radius: 2px;
}
.sx-lamp-i {
  display: block; width: 100%; height: 100%;
  background: url(/assets/ax-sprite.webp) 0 80% / 600% 600% no-repeat;   /* frame 24: X, raking */
}
.js .sx-lamp-i { background-position: 0 20%; }                         /* frame 6: A, front */
@media (prefers-reduced-motion: reduce) { .js .sx-lamp-i { background-position: 0 80%; } }
:root[data-theme="dark"] .sx-lamp-i { background-image: url(/assets/ax-sprite-dark.webp); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sx-lamp-i { background-image: url(/assets/ax-sprite-dark.webp); } }
.sx-light { display: inline-flex; flex: none; border: 1px solid var(--rule); border-radius: 4px; }
.sx-light button {
  min-height: 44px; padding: 0 12px; font: 400 13px/1 var(--font-text); color: var(--ink-2);
  background: none; border: 0; border-radius: 3px; cursor: pointer; white-space: nowrap;
  transition: color var(--t1) var(--ease), background var(--t1) var(--ease);
}
.sx-light button + button { border-left: 1px solid var(--rule); border-radius: 0 3px 3px 0; }
.sx-light button:first-child { border-radius: 3px 0 0 3px; }
.sx-light button[aria-pressed="true"] { color: var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); }
.sx-light button:hover { color: var(--ink); }
html:not(.js) .sx-light { display: none; }

.sx-hero .sx-frame { margin-left: var(--sx-off); }
/* the sheet's label (legend(), placed by home.css): what the relief means, the drag hint, where the form is from */
.sx-note { margin: 0; font-size: 13px; line-height: 1.6; color: var(--ink); }
.sx-hint { display: none; margin: 8px 0 0; font: 400 12.5px/1.5 var(--font-mono); color: var(--ink-2); }
:lang(ko) .sx-hint { font-family: var(--font-text); }
.sx-foot { margin: 8px 0 0; font-size: 13px; line-height: 1.6; color: var(--ink-2); }
.sx-out { margin: 20px 0 0 var(--sx-off); }
.sx-out .cmd pre { font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.sx-cmd { margin: 8px 0 0; font: 400 12px/1.5 var(--font-mono); color: var(--ink-2); overflow-wrap: anywhere; }
.sx-cmd code { background: none; padding: 0; font-size: 1em; }
.sx-flagline { margin: 0; padding: 14px 16px; font-size: 14.5px; line-height: 1.6; }
.sx-script { margin: 20px 0 0 var(--sx-off); padding: 0 0 0 1.4em; font-size: 13.5px; line-height: 1.6; color: var(--ink-2); }
.sx-script li + li { margin-top: 4px; }
.js .sx-script { display: none; }

/* ---------- the plan slip, clipped to the sheet's left edge */
.slip {
  --ink: #17181b; --ink-2: #5d5e63; --pencil: #2f55c8; --flag: #9a5b13; --seal: #c8281e; --on-ink: #f3f1ea;
  --rule: #d9d5ca; --paper: #f3f1ea;
  position: absolute; z-index: 2; top: calc(var(--u, 1cqw) * 37); right: calc(100% - 5.2cqw);
  width: calc(var(--sx-off) + 5.2cqw - 4px);
  padding: 16px 14px 14px; color: var(--ink);
  background: color-mix(in srgb, var(--sheet) 62%, #fff);
  border: 1px solid rgb(23 24 27 / .13); border-radius: 1px;
  font: 400 13px/1.45 var(--font-text); transform: rotate(-.6deg); transform-origin: 100% 0;
}
.slip p { margin: 0; }
.slip-clip {
  position: absolute; right: calc(2.6cqw - 9px); top: -40px; width: 18px; height: 52px; overflow: visible;
  fill: none; stroke: #8b8c91; stroke-width: 1.5; stroke-linecap: round; z-index: 3;
}
.slip-k { font: 500 11px/1.4 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
:lang(ko) .slip-k { font: 600 13px/1.4 var(--font-text); letter-spacing: 0; text-transform: none; color: var(--ink); }
.slip-n { margin-top: 6px !important; font-weight: 500; font-size: 13.5px; line-height: 1.4; }
.slip-n span { display: block; }
.slip-f { min-height: 2.9em; margin-top: 2px !important; font: 400 11.5px/1.45 var(--font-mono); color: var(--flag); }
.slip-f:empty { min-height: 0; }
.slip-f .plan { color: var(--ink-2); }
.slip-f .slip-say { display: block; margin-bottom: 2px; font: 400 11.5px/1.45 var(--font-text); color: var(--ink-2); }
.slip-nojs-k { display: block; font-family: var(--font-text); color: var(--ink-2); }
.slip-seal { position: relative; display: flex; flex-direction: column; align-items: center; margin: 12px 0 12px; }
.seal { width: 66px; height: 66px; overflow: visible; }
.slip-seal::before {
  content: ''; position: absolute; top: 3px; left: 50%; width: 60px; height: 60px; transform: translateX(-50%);
  border: 1px solid rgb(23 24 27 / .2); border-radius: 1px;   /* the 결재 cell: a printed hairline box */
}
.slip-seal-l { margin-top: 2px; font-size: 11px; line-height: 1.3; color: var(--ink-2); }
.seal-ghost { color: var(--seal); opacity: 0; }
.seal-ink { color: var(--seal); }
.seal-frame { fill: none; stroke: currentColor; stroke-width: .13; }
.seal-mk { overflow: visible; }
.seal > g { transform: rotate(-5deg); transform-origin: 0 0; }
.slip-act { display: grid; gap: 8px; }
.slip-act .btn { width: 100%; min-height: 44px; padding: 0 10px; font-size: 14px; }
.slip-act .btn[hidden] { display: none; }
.slip-ok {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--ink); color: var(--on-ink); border-color: var(--ink);
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.slip-ok:hover { background: color-mix(in srgb, var(--ink) 86%, var(--paper)); }
/* holding paints the button seal-red from the left, then the stamp lands: one colour, one meaning (on-ink on seal 4.92:1) */
.slip-ok::before {
  content: ''; position: absolute; inset: 0; z-index: -1; background: var(--seal);
  transform: scaleX(var(--p, 0)); transform-origin: 0 50%;
}
.slip-act .slip-ret {
  border: 0; background: none; min-height: 44px; color: var(--ink-2);
  text-decoration: underline; text-underline-offset: .25em; text-decoration-thickness: 1px;
}
.slip-act .slip-ret:hover { background: none; color: var(--ink); }
.slip-act .btn[aria-disabled="true"] { opacity: .45; cursor: default; }
.slip-hint { margin-top: 8px !important; font-size: 11.5px; line-height: 1.4; color: var(--ink-2); text-align: center; }
html:not(.js) .slip-act, html:not(.js) .slip-hint { display: none; }
.sx[data-state^="approved"] .slip-hint, .sx[data-state="returned"] .slip-hint { visibility: hidden; }
.sx[data-state^="approved"] .slip-seal::before { border-color: transparent; }
.sx[data-state="returned"] .slip-k { color: var(--ink); }

/* the static seal in the compact variant */
.seal-stamp { position: absolute; top: 3px; left: 50%; width: 60px; height: 60px; display: grid; place-items: center; border: 4px solid var(--seal); color: var(--seal); transform: translateX(-50%) rotate(-5deg); border-radius: 2px; }
.seal-stamp .seal-mark { width: 44px; height: 44px; }

/* ---------- desktop: tilt and drag */
@media (min-width: 768px) {
  .sx-hero .sx-plane { transform: perspective(2400px) rotateX(6deg); transform-origin: 50% 0; }
  .sx-plane.measuring { transform: none !important; }
  .js .sx-hero .sx-plane { cursor: grab; }
  .js .sx-hero .sx-plane.dragging { cursor: grabbing; -webkit-user-select: none; user-select: none; }
  .js .sx-hero .sx-plane.dragging * { -webkit-user-select: none; user-select: none; }
  .sx-plane .slip { cursor: auto; }
}
@media (min-width: 768px) and (hover: hover) and (pointer: fine) {
  .js .sx-hint { display: block; }
}

/* ---------- mobile: the sheet crops to 두문, 본문 and the 결재 row at full width; no tilt, no drag */
@media (max-width: 767px) {
  .sx { --sx-off: 0px; }
  .sx-top { margin: 0 0 14px; gap: 12px; justify-content: space-between; }
  .sx-lamp { position: relative; left: auto; transform: none; width: 48px; height: 48px; flex: none; }
  .sx-hero .sheet {
    --u: 1.62cqw; aspect-ratio: auto;
    padding: calc(var(--u) * 6) calc(var(--u) * 4.5) calc(var(--u) * 3);
  }
  .sx-hero .gm-cap, .sx-hero .gm-from, .sx-hero .gm-rb, .sx-hero .gm-rc, .sx-hero .gm-rd, .sx-hero .gm-re,
  .sx-hero .gm-size, .sx-hero .gm-bigo { display: none; }
  .sx-hero .gm-org { margin-top: 0 !important; }
  .sx-hero .gm-rows { margin-top: calc(var(--u) * 4); border-bottom: 0; }
  .sx-hero .gm-rows tbody { padding-bottom: 0; }
  .sx-hero .gm-tab { right: calc(var(--u) * 5); }
  /* no room in the margin for the word: a change bar beside the line, so nothing reflows when guard runs */
  .sx-hero .is-flag::after { content: ''; left: auto; right: 100%; top: .3em; margin: 0 calc(var(--u) * 1.6) 0 0; padding: 0; width: 3px; height: 1.1em; border: 0; border-radius: 1px; background: var(--flag); }
  .sx-hero .slip {
    position: relative; top: auto; right: auto; width: auto; margin: -6px 10px 0 18px; transform: none;
    display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; padding: 16px;
  }
  .sx-hero .slip > p { grid-column: 1; }
  .sx-hero .slip-seal { grid-column: 2; grid-row: 1 / span 3; margin: 0; }
  .sx-hero .slip-act { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; margin-top: 14px; }
  .sx-hero .slip-act .slip-reset { grid-column: 1 / -1; }
  .sx-hero .slip-hint { grid-column: 1 / -1; }
  .sx-hero .slip-clip { right: 18px; left: auto; top: -40px; }
  .sx-out, .sx-script { margin-left: 0; }
}

/* ---------- compact: the same sheet, small and static (the home page's loop section) */
.sx-compact { --sx-off: 0px; }
/* cropped like the phone hero: 두문, 본문 and the 결재 row, large enough to read in a narrow column */
.sx-compact .sheet { --u: 1.5cqw; aspect-ratio: auto; padding: calc(var(--u) * 5) calc(var(--u) * 4.5) calc(var(--u) * 3); }
.sx-compact .gm-from, .sx-compact .gm-rb, .sx-compact .gm-rc, .sx-compact .gm-rd, .sx-compact .gm-re,
.sx-compact .gm-size, .sx-compact .gm-bigo { display: none; }
.sx-compact .gm-org { margin-top: calc(var(--u) * 2.4) !important; }
.sx-compact .gm-rows { margin-top: calc(var(--u) * 3); border-bottom: 0; }
.sx-compact .gm-rows tbody { padding-bottom: 0; }
.sx-compact .gm-tab { right: calc(var(--u) * 5); }
.sx-compact .sheet .rl { box-shadow: none; }   /* no lamp here: the struck guide text is the only mark */
.sx-compact[data-state^="approved"] .sx-plane, .sx-compact[data-state="original"] .sx-plane { --amp: 0; }
.sx-compact .slip {
  position: relative; top: auto; right: auto; width: auto; margin: -10px 10px 0 16px; transform: rotate(-.6deg);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; padding: 12px 12px 10px;
}
.sx-compact .slip-k, .sx-compact .slip-n { grid-column: 1; }
.sx-compact .slip-n { font-size: 12.5px; }
.sx-compact .slip-seal { grid-column: 2; grid-row: 1 / span 2; margin: 0; }
.sx-compact .slip-seal::before { width: 44px; height: 44px; }
.sx-compact .slip-seal-l { display: none; }
.sx-compact .seal-stamp { width: 44px; height: 44px; border-width: 3px; }
.sx-compact .seal-stamp .seal-mark { width: 32px; height: 32px; }
.sx-compact .slip-seal { min-width: 50px; min-height: 50px; }
.sx-compact .slip-clip { right: auto; left: 14px; top: -34px; }
