/* =====================================================================
   KMSO Score Check — modern stylesheet (v2)
   Palette:  ink navy backdrop · white result sheet · gold = award only
   Type:     Fraunces (display) · Inter (body) · Space Mono (data)
   Notes:    mobile-first, larger touch targets, safe-area aware,
             accessible focus states, print & reduced-motion support.
   ===================================================================== */

:root {
  --ink:        #0B1F3A;   /* darkest text / navy */
  --navy:       #14365C;
  --navy-2:     #0E2A4E;
  --slate:      #5B6B7F;   /* secondary text */
  --slate-2:    #7A8798;   /* tertiary / hints */
  --line:       #E6EAF0;   /* hairlines */
  --line-2:     #D7DEE8;   /* stronger hairline */
  --paper:      #FFFFFF;   /* result sheet */
  --field:      #F4F7FB;   /* input background */

  --gold:       #B8902A;   /* achievement gold — reserved for awards */
  --gold-deep:  #8C6A12;
  --gold-soft:  #FBF3D8;

  --silver:     #7E8AA0;
  --bronze:     #B0703B;

  --shadow:     0 24px 60px -24px rgba(7, 22, 44, .55);
  --shadow-sm:  0 2px 10px -4px rgba(7, 22, 44, .30);
  --radius:     18px;
  --radius-sm:  12px;

  --maxw:       760px;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, #1d5a99 0%, transparent 60%),
    linear-gradient(165deg, var(--navy-2) 0%, var(--navy) 55%, #0a2240 100%);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* iPhone 노치/홈 인디케이터 안전영역 반영 */
  padding:
    calc(env(safe-area-inset-top, 0px) + 34px)
    max(16px, env(safe-area-inset-right, 0px))
    calc(env(safe-area-inset-bottom, 0px) + 48px)
    max(16px, env(safe-area-inset-left, 0px));
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- skip link (a11y) ------------------------------------------- */
.skip-link {
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translate(-50%, -160%);
  background: #fff;
  color: var(--navy);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  text-decoration: none;
  z-index: 10;
  transition: transform .18s ease;
}
.skip-link:focus { transform: translate(-50%, 0); outline: 3px solid var(--gold); }

/* ---- masthead ---------------------------------------------------- */
.masthead {
  width: 100%;
  max-width: var(--maxw);
  color: #fff;
  text-align: center;
  margin-bottom: 22px;
}
.masthead .eyebrow {
  font-family: "Space Mono", ui-monospace, monospace;
  letter-spacing: .32em;
  text-transform: uppercase;
  font-size: 11px;
  color: #9ec3ea;
  margin: 0 0 8px;
}
.masthead h1 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: clamp(26px, 6.4vw, 42px);
  line-height: 1.06;
  margin: 0;
  letter-spacing: -.01em;
  text-wrap: balance;
}
.masthead h1 .amp { color: var(--gold); font-style: italic; }

/* ---- brand logo slot (branding.php) ----------------------------- */
.brand-logo { margin: 0 0 14px; line-height: 0; }
.brand-logo a { display: inline-block; line-height: 0; }
.brand-logo img {
  height: auto;
  max-height: var(--logo-maxh, 76px);
  max-width: min(100%, 340px);
  width: auto;
  display: inline-block;
  /* 어두운 배경 위 로고 가독성 향상용 (원하면 branding에서 조정) */
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, .28));
}
@media (max-width: 560px) {
  .brand-logo img { max-height: min(var(--logo-maxh, 76px), 56px); }
  .brand-logo { margin-bottom: 10px; }
}

/* ---- sheet (the white card) ------------------------------------- */
.sheet {
  width: 100%;
  max-width: var(--maxw);
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.sheet + .sheet { margin-top: 26px; }

.sheet__head {
  padding: clamp(22px, 5vw, 30px) clamp(22px, 5vw, 38px) 20px;
  border-bottom: 1px solid var(--line);
}
.sheet__head h2 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: clamp(20px, 4.4vw, 22px);
  margin: 0 0 4px;
}
.sheet__head p { margin: 0; color: var(--slate); font-size: 14px; word-break: break-word; }
.sheet__body { padding: clamp(24px, 5.6vw, 32px) clamp(22px, 5vw, 38px) clamp(28px, 6vw, 36px); }

/* ---- entrance animation ----------------------------------------- */
.reveal { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- form -------------------------------------------------------- */
.field { margin-bottom: 20px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--slate);
  margin-bottom: 8px;
}
.field input,
.field select {
  width: 100%;
  font-size: 16px;            /* 16px = iOS에서 확대 방지 */
  font-family: inherit;
  color: var(--ink);
  background: var(--field);
  border: 1.5px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 15px 16px;         /* 넉넉한 터치 타깃 */
  transition: border-color .15s, box-shadow .15s, background .15s;
  -webkit-appearance: none;
  appearance: none;
}
.field input::placeholder { color: #9aa7b6; }
.field input:hover,
.field select:hover { border-color: #c3ccd9; }
.field input:focus,
.field select:focus {
  outline: none;
  background: #fff;
  border-color: var(--navy);
  box-shadow: 0 0 0 4px rgba(20, 54, 92, .13);
}
.field .hint { margin-top: 7px; font-size: 12.5px; color: var(--slate-2); line-height: 1.45; }

/* custom select chevron */
.select-wrap { position: relative; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 16px; top: 50%;
  width: 10px; height: 10px;
  border-right: 2px solid var(--slate);
  border-bottom: 2px solid var(--slate);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.select-wrap select { padding-right: 40px; cursor: pointer; }

/* ---- button ------------------------------------------------------ */
.btn {
  position: relative;
  width: 100%;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, #1a4372, var(--navy));
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 6px;
  min-height: 52px;
  box-shadow: var(--shadow-sm);
  transition: transform .08s ease, background .15s, box-shadow .15s, opacity .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn:hover  { background: linear-gradient(180deg, #16375d, var(--ink)); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn:disabled { cursor: default; opacity: .85; }

.btn__spinner {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  display: none;
  animation: spin .7s linear infinite;
}
.btn.is-loading .btn__spinner { display: inline-block; }
.btn.is-loading .btn__label { opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- award banner (the signature) ------------------------------- */
.award-banner {
  position: relative;
  margin-bottom: 26px;
  border: 1.5px solid var(--gold);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--gold-soft), #fff 78%);
  box-shadow: 0 12px 30px -18px rgba(140, 106, 18, .55);
  padding: 22px 24px;
  display: flex;
  align-items: flex-start;
  gap: 18px;
}
.award-banner .seal {
  flex: 0 0 auto;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f3dd8a, var(--gold) 72%);
  box-shadow: 0 4px 12px -2px rgba(140, 106, 18, .55), inset 0 0 0 2px #fff;
  display: grid; place-items: center;
  color: #fff; font-size: 23px;
  margin-top: 2px;
}
.award-banner__body { min-width: 0; }
.award-banner h3 {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(17px, 4vw, 19px);
  margin: 0 0 6px;
  color: var(--gold-deep);
  line-height: 1.2;
}
.award-banner p     { margin: 0; font-size: 14px; color: #5a4a1e; line-height: 1.5; }
.award-banner p.ko  { margin-top: 8px; color: #7a6428; }

/* ---- subject result card ---------------------------------------- */
.result-card {
  border: 1px solid var(--line-2);
  border-radius: 16px;
  padding: 22px 24px;
  margin-bottom: 18px;
  background: #fff;
}
.result-card--award {
  border-color: #ecdca4;
  background: linear-gradient(180deg, #fffdf6, #fff);
}
.result-card__top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.result-card__title {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(16px, 3.8vw, 18px); font-weight: 600; margin: 0;
  line-height: 1.25;
}
.result-card__title .yr { color: var(--slate); font-weight: 400; }

.medal {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600;
  padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--line-2);
  white-space: nowrap;
}
.medal .dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.medal.gold        { background: var(--gold-soft); color: var(--gold-deep); border-color: #e9d79a; }
.medal.gold .dot   { background: var(--gold); }
.medal.silver      { background: #f1f3f7; color: #4f5a6e; }
.medal.silver .dot { background: var(--silver); }
.medal.bronze      { background: #f7efe7; color: #8a5328; }
.medal.bronze .dot { background: var(--bronze); }
.medal.commendation      { background: #eef4fb; color: var(--navy); }
.medal.commendation .dot { background: var(--navy); }

/* stats: responsive grid — 3 across on wide, 2 across on phones */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 20px;
}
.stat { min-width: 0; }
.stat .k {
  font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--slate); margin-bottom: 5px;
}
.stat .v {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: clamp(22px, 6vw, 26px); font-weight: 700; color: var(--ink); line-height: 1.05;
  overflow-wrap: anywhere;
}
.stat .v.name { font-family: "Inter", sans-serif; font-size: clamp(16px, 4.4vw, 19px); font-weight: 600; }

/* ---- not-found / messages --------------------------------------- */
.notice {
  text-align: center; padding: 12px 0 6px;
}
.notice__icon {
  width: 54px; height: 54px; margin: 0 auto 14px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: #eef2f8; color: var(--slate);
  font-family: "Fraunces", Georgia, serif; font-size: 28px; font-weight: 600;
}
.notice h3 {
  font-family: "Fraunces", Georgia, serif; font-size: 20px; margin: 0 0 8px;
}
.notice p { color: var(--slate); margin: 0 auto 6px; font-size: 14px; max-width: 42ch; }
.notice a { color: var(--navy); font-weight: 600; }

/* ---- back link & footer ----------------------------------------- */
.backlink {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 10px; font-weight: 600; font-size: 14px;
  color: var(--navy); text-decoration: none;
  padding: 8px 2px; /* 터치 타깃 */
}
.backlink:hover { text-decoration: underline; }
.backlink:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 6px; }

.footer {
  width: 100%; max-width: var(--maxw);
  text-align: center; margin-top: 24px;
  color: #aebfd6; font-size: 12px;
  font-family: "Space Mono", ui-monospace, monospace; letter-spacing: .04em;
  line-height: 1.7;
}
.footer a { color: #cdddf2; text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ---- phones ------------------------------------------------------ */
@media (max-width: 560px) {
  .award-banner {
    flex-direction: column;
    gap: 12px;
    padding: 20px 18px;
  }
  .award-banner .seal { margin-top: 0; }
  .result-card { padding: 20px 18px; }
  .result-card__top { margin-bottom: 16px; }
  .medal { font-size: 12.5px; }
  /* Name / Group 은 한 줄 폭, Score 는 그 아래 강조 */
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 360px) {
  .stat-row { grid-template-columns: 1fr; gap: 14px; }
}

/* ---- reduced motion --------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  html { scroll-behavior: auto; }
}

/* ---- print (students may print their result) -------------------- */
@media print {
  body {
    background: #fff; color: #000; padding: 0; display: block;
  }
  .masthead { color: #000; margin: 0 0 12px; }
  .masthead .eyebrow, .footer, .backlink, .skip-link { display: none !important; }
  .sheet { box-shadow: none; border: 1px solid #ccc; max-width: 100%; }
  .award-banner { box-shadow: none; }
  .reveal { animation: none; }
}
