/* Genshin Impact Codes — stylesheet
   One file, no frameworks, no external requests. */

:root{
  --bg:#f7f8fa;
  --panel:#ffffff;
  --ink:#16181d;
  --ink-soft:#5b616e;
  --line:#e3e6ec;
  --line-strong:#cdd2db;
  --accent:#3b5bdb;
  --accent-soft:#eef1fd;
  --ok-bg:#e7f6ec;
  --ok-ink:#1a6b36;
  --wait-bg:#fff4e0;
  --wait-ink:#8a5300;
  --exp-bg:#f2f3f5;
  --exp-ink:#5b616e;
  --code-bg:#f0f2f6;
  --radius:10px;
}

*{box-sizing:border-box;}

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

body{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font:16px/1.55 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif;
}

.wrap{max-width:1000px;margin:0 auto;padding:0 16px;}

.sr-only{
  position:absolute;width:1px;height:1px;padding:0;margin:-1px;
  overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;
}

/* ---------- header ---------- */

.top{
  background:var(--panel);
  border-bottom:1px solid var(--line);
  padding:18px 0 14px;
}

.top h1{
  margin:0 0 6px;
  font-size:26px;
  line-height:1.2;
  letter-spacing:-0.01em;
}

.statusline{
  margin:0 0 8px;
  font-size:14px;
  color:var(--ink-soft);
}

.statusline strong{color:var(--ink);}

.disclaimer{
  margin:0;
  font-size:13px;
  line-height:1.5;
  color:var(--ink-soft);
  max-width:72ch;
}

.disclaimer a{color:var(--accent);}

/* ---------- sections ---------- */

section{margin:26px 0;}

h2{
  font-size:19px;
  margin:0 0 10px;
  letter-spacing:-0.01em;
}

h3{
  font-size:16px;
  margin:20px 0 8px;
}

p{margin:0 0 10px;}

a{color:var(--accent);}

ul.tight,ol.steps{margin:0 0 10px;padding-left:22px;}

ul.tight li,ol.steps li{margin:0 0 6px;}

.small{font-size:13.5px;color:var(--ink-soft);line-height:1.55;}

.callout{
  background:var(--accent-soft);
  border-left:3px solid var(--accent);
  border-radius:0 var(--radius) var(--radius) 0;
  padding:10px 12px;
  font-size:14px;
  margin:10px 0;
}

/* ---------- code + copy ---------- */

.code{
  font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace;
  font-size:14px;
  background:var(--code-bg);
  border:1px solid var(--line);
  border-radius:6px;
  padding:2px 6px;
  /* keep the whole string selectable and never clip it */
  -webkit-user-select:all;
  user-select:all;
  overflow-wrap:anywhere;
  word-break:break-word;
  white-space:normal;
  display:inline;
}

.small-code{font-size:12.5px;}

button.copy{
  font:inherit;
  font-size:12px;
  line-height:1;
  margin-left:6px;
  padding:5px 9px;
  border:1px solid var(--line-strong);
  background:var(--panel);
  color:var(--ink-soft);
  border-radius:6px;
  cursor:pointer;
  white-space:nowrap;
  vertical-align:middle;
}

button.copy:hover{border-color:var(--accent);color:var(--accent);}

button.copy:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}

button.copy.done{
  background:var(--ok-bg);
  border-color:#b7e0c4;
  color:var(--ok-ink);
}

/* ---------- status pills ---------- */

.pill{
  display:inline-block;
  font-size:12px;
  line-height:1.5;
  padding:1px 8px;
  border-radius:999px;
  white-space:nowrap;
  font-weight:600;
}

.pill.ok{background:var(--ok-bg);color:var(--ok-ink);}
.pill.wait{background:var(--wait-bg);color:var(--wait-ink);}
.pill.exp{background:var(--exp-bg);color:var(--exp-ink);}

/* ---------- tables ---------- */

table.codes{
  width:100%;
  border-collapse:collapse;
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:var(--radius);
  overflow:hidden;
  font-size:14.5px;
  table-layout:fixed;
}

table.codes thead th{
  text-align:left;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:0.04em;
  color:var(--ink-soft);
  background:#fbfcfd;
  border-bottom:1px solid var(--line);
  padding:10px 12px;
  font-weight:600;
}

table.codes td{
  padding:11px 12px;
  border-bottom:1px solid var(--line);
  vertical-align:top;
}

table.codes tbody tr:last-child td{border-bottom:0;}

/* column widths: code / status / date / reward / source */
table.codes th:nth-child(1),table.codes td:nth-child(1){width:26%;}
table.codes th:nth-child(2),table.codes td:nth-child(2){width:13%;}
table.codes th:nth-child(3),table.codes td:nth-child(3){width:12%;}
table.codes th:nth-child(4),table.codes td:nth-child(4){width:28%;}
table.codes th:nth-child(5),table.codes td:nth-child(5){width:21%;}

table.codes td.src{
  font-size:13px;
  color:var(--ink-soft);
  overflow-wrap:anywhere;
}

table.codes td.src .more{white-space:nowrap;}

table.codes.expired{font-size:14px;}

.tablenote{
  margin-top:10px;
  font-size:13.5px;
  color:var(--ink-soft);
  line-height:1.55;
}

/* ---------- reasons list ---------- */

dl.reasons{margin:0;}

dl.reasons dt{
  font-weight:600;
  margin-top:12px;
}

dl.reasons dd{
  margin:2px 0 0;
  font-size:14.5px;
  color:var(--ink-soft);
  line-height:1.55;
}

/* ---------- faq ---------- */

.faq h3{margin-top:16px;}

.faq p{font-size:14.5px;color:var(--ink-soft);line-height:1.6;}

/* ---------- footer ---------- */

.foot{
  margin-top:34px;
  padding:20px 0 34px;
  border-top:1px solid var(--line);
  background:var(--panel);
  font-size:13px;
  color:var(--ink-soft);
  line-height:1.6;
}

.foot p{margin:0 0 10px;}

/* =========================================================
   MOBILE — the table becomes one card per code.
   Nothing is allowed to scroll sideways and no code is
   truncated, so the full string is always selectable.
   ========================================================= */

@media (max-width:680px){

  .wrap{padding:0 12px;}

  .top h1{font-size:22px;}

  table.codes{
    border:0;
    border-radius:0;
    background:transparent;
    table-layout:auto;
    font-size:14.5px;
  }

  table.codes thead{
    /* keep it for screen readers, hide it visually,
       and make sure it can never contribute to page width */
    position:absolute;
    display:block;
    width:1px;
    max-width:1px;
    height:1px;
    overflow:hidden;
    clip:rect(0 0 0 0);
    clip-path:inset(50%);
    white-space:nowrap;
    pointer-events:none;
    border:0;
  }

  table.codes thead tr,
  table.codes thead th{
    display:block;
    width:1px;
    max-width:1px;
    height:1px;
    padding:0;
    margin:0;
    border:0;
    overflow:hidden;
    white-space:nowrap;
  }

  table.codes tbody,
  table.codes tr,
  table.codes td{
    display:block;
    width:auto !important;
  }

  table.codes tr{
    background:var(--panel);
    border:1px solid var(--line);
    border-radius:var(--radius);
    padding:10px 12px 12px;
    margin:0 0 10px;
  }

  table.codes td{
    border:0;
    padding:3px 0;
    max-width:100%;
  }

  /* label each field on its own line */
  table.codes td[data-label]::before{
    content:attr(data-label);
    display:block;
    font-size:11px;
    text-transform:uppercase;
    letter-spacing:0.04em;
    color:var(--ink-soft);
    font-weight:600;
    margin-bottom:1px;
  }

  /* the code itself gets its own emphasis and can wrap anywhere */
  table.codes td[data-label="Code"] .code{
    font-size:15px;
    display:inline;
    overflow-wrap:anywhere;
    word-break:break-all;
  }

  table.codes td[data-label="Code"]::before{margin-bottom:3px;}

  button.copy{
    margin-left:8px;
    padding:6px 10px;
  }

  table.codes.expired tr{background:#fcfcfd;}

  table.codes.expired td[data-label="Code"] .code{
    color:var(--ink-soft);
  }
}
