/*****************************************************************************/
/* Tufte-style theme for PS1 Generator
/* Based on Tufte CSS (https://github.com/edwardtufte/tufte-css)
/* matching zhyantao.github.io (tufte-jekyll theme)
/*****************************************************************************/

/* ---------- Fonts (et-book, same as reference site) ----------
   Rebuilt without TrueType bytecode hinting: the hints shipped with ET Book
   render distorted glyphs on Windows (macOS ignores them). */
@font-face {
  font-family: "ETBembo";
  src: url("../fonts/et-book/et-book-roman-line-figures.woff2") format("woff2"),
    url("../fonts/et-book/et-book-roman-line-figures.woff") format("woff"),
    url("../fonts/et-book/et-book-roman-line-figures.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "ETBembo";
  src: url("../fonts/et-book/et-book-display-italic-old-style-figures.woff2")
      format("woff2"),
    url("../fonts/et-book/et-book-display-italic-old-style-figures.woff")
      format("woff"),
    url("../fonts/et-book/et-book-display-italic-old-style-figures.ttf")
      format("truetype");
  font-weight: normal;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "ETBembo";
  src: url("../fonts/et-book/et-book-bold-line-figures.woff2") format("woff2"),
    url("../fonts/et-book/et-book-bold-line-figures.woff") format("woff"),
    url("../fonts/et-book/et-book-bold-line-figures.ttf") format("truetype");
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "ETBemboOldStyle";
  src: url("../fonts/et-book/et-book-roman-old-style-figures.woff2")
      format("woff2"),
    url("../fonts/et-book/et-book-roman-old-style-figures.woff") format("woff"),
    url("../fonts/et-book/et-book-roman-old-style-figures.ttf")
      format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ---------- Palette (same constants as reference _settings.scss) ---------- */
:root {
  --text-color: #111111;
  --bg-color: #fffff8;
  --contrast-color: #a00000;
  --border-color: #333333;
  --border-soft: rgba(51, 51, 51, 0.25);
  --body-font: "ETBembo", "Chronicle Text G2", Palatino, "Palatino Linotype",
    "Palatino LT STD", "Book Antiqua", Georgia, "Songti SC", "STSong", "SimSun",
    serif;
  --sans-font: "Gill Sans", "Gill Sans MT", "Gotham Narrow", Lato, Calibri,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --code-font: Consolas, "Liberation Mono", Menlo, Courier, "PingFang SC",
    monospace;
}

/* ---------- Global resets ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  font-size: 11px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
@media screen and (min-width: 800px)  { html { font-size: 12px; } }
@media screen and (min-width: 900px)  { html { font-size: 13px; } }
@media screen and (min-width: 1000px) { html { font-size: 14px; } }
@media screen and (min-width: 1100px) { html { font-size: 15px; } }
@media screen and (min-width: 1200px) { html { font-size: 16px; } }
@media screen and (min-width: 1300px) { html { font-size: 17px; } }

/* 居中布局：工具页无边注（sidenote），不采用 Tufte 默认的 12.5% 左侧留白 */
body {
  width: 87.5%;
  margin-left: auto;
  margin-right: auto;
  font-family: var(--body-font);
  background-color: var(--bg-color);
  color: var(--text-color);
  max-width: 1000px;
}
@media screen and (max-width: 760px) {
  body {
    width: 90%;
  }
}

/* ---------- Typography ---------- */
h1 {
  font-weight: 400;
  margin-top: 1.568rem;
  margin-bottom: 1.568rem;
  font-size: 2.5rem;
  line-height: 1.1;
}

h2 {
  font-style: italic;
  font-weight: 400;
  margin-top: 1.866666666666667rem;
  margin-bottom: 0.6rem;
  font-size: 2.1rem;
  line-height: 1.1;
}

h3 {
  font-style: italic;
  font-weight: 400;
  font-size: 1.8rem;
  margin-top: 2.1777777777777778rem;
  margin-bottom: 0;
  line-height: 1.1;
}

p,
ol,
ul {
  font-size: 1.4rem;
}
p,
li {
  line-height: 2rem;
}

a {
  color: var(--contrast-color);
  text-decoration: none;
}
p > a,
span > a,
li > a {
  color: var(--text-color);
  text-decoration: none;
  background: linear-gradient(var(--bg-color), var(--bg-color)),
    linear-gradient(var(--bg-color), var(--bg-color)),
    linear-gradient(currentColor, currentColor);
  background-size: 0.05em 1px, 0.05em 1px, 1px 1px;
  background-repeat: no-repeat, no-repeat, repeat-x;
  text-shadow: 0.03em 0 var(--bg-color), -0.03em 0 var(--bg-color),
    0 0.03em var(--bg-color), 0 -0.03em var(--bg-color),
    0.06em 0 var(--bg-color), -0.06em 0 var(--bg-color),
    0.09em 0 var(--bg-color), -0.09em 0 var(--bg-color);
  background-position: 0% 93%, 100% 93%, 0% 93%;
}

.sans {
  font-family: var(--sans-font);
  letter-spacing: 0.03em;
}

pre,
code {
  font-family: var(--code-font);
  font-size: 1.2rem;
}

hr.slender {
  border: 0;
  height: 1px;
  margin-top: 1.4rem;
  margin-bottom: 1.4rem;
  background-image: linear-gradient(
    left,
    rgba(0, 0, 0, 0),
    rgba(0, 0, 0, 0.75),
    rgba(0, 0, 0, 0)
  );
  background-image: -webkit-linear-gradient(
    left,
    rgba(0, 0, 0, 0),
    rgba(0, 0, 0, 0.75),
    rgba(0, 0, 0, 0)
  );
}

/* ---------- Nav (uppercase sans, like reference header) ---------- */
header.site-header > nav.group {
  width: 95%;
  padding-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}
header.site-header > nav.group a {
  font-size: 1.2rem;
  font-family: var(--sans-font);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--contrast-color);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 0;
  padding-right: 2rem;
  vertical-align: baseline;
}
header.site-header > nav.group a:hover {
  color: var(--text-color);
}
header.site-header > nav.group a img.badge {
  height: 2.4rem;
  width: auto;
  display: block;
  padding-right: 0.6rem;
}
header.site-header > nav.group a.active:before {
  content: "\0003c\000a0";
}
header.site-header > nav.group a.active:after {
  content: "\000a0\0003e";
}

/* ---------- Footer ---------- */
body footer.site-footer {
  width: 95%;
  padding-top: 2rem;
  padding-bottom: 2rem;
}
ul.footer-links {
  list-style: none;
  text-align: center;
  margin: 0 auto;
}
ul.footer-links li {
  display: inline;
  padding: 0.5rem 0.25rem;
}
ul.footer-links a {
  color: var(--contrast-color);
  text-decoration: none;
}
ul.footer-links svg {
  vertical-align: middle;
}
.credits {
  font-family: var(--sans-font);
  padding: 1rem 0rem;
  text-align: center;
  font-size: 1.2rem;
}
.credits a {
  color: var(--contrast-color);
}

/* ---------- App panels: hairline boxes, no shadows, no rounding ---------- */
.panel {
  border: 1px solid var(--border-soft);
  background: transparent;
  padding: 1.6rem 1.8rem;
  margin-bottom: 2rem;
}
.panel > h2,
.panel > h3 {
  margin-top: 0;
}
.panel-title {
  font-style: italic;
  font-weight: 400;
  font-size: 1.8rem;
  margin-bottom: 1rem;
  line-height: 1.1;
}
.panel-caption {
  font-family: var(--sans-font);
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--border-color);
}

.subtitle {
  color: var(--border-color);
  font-size: 1.3rem;
}
.hint {
  font-size: 1.05rem;
  color: var(--border-color);
  margin-top: 0.8rem;
}

/* ---------- PS1 终端预览（保留暗色终端观感） ---------- */
.preview-wrap {
  border: 1px solid var(--border-soft);
  margin: 0 0 2rem;
  overflow: hidden;
}
.preview-bar {
  background: rgba(51, 51, 51, 0.05);
  border-bottom: 1px solid var(--border-soft);
  color: var(--border-color);
  font-family: var(--sans-font);
  font-size: 1.05rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.preview-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.preview {
  background-color: #161616;
  color: #e8e6e3;
  padding: 1.2rem 1.4rem;
  min-height: 4.5rem;
  white-space: pre;
  font-family: var(--code-font);
  font-size: 1.25rem;
  line-height: 1.8;
  overflow-x: auto;
}
.preview span {
  padding: 2px 6px;
  border-radius: 2px;
}
.preview span.sep {
  padding: 2px 0;
}
.preview span.prompt {
  padding-right: 0;
}
.preview span.tight-right {
  padding-right: 0;
}
.preview span.tight-left {
  padding-left: 0;
}

/* ---------- 配置分区 ---------- */
.section {
  padding-bottom: 1.4rem;
  margin-bottom: 1.4rem;
  border-bottom: 1px solid var(--border-soft);
}
.section:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}
.section h3 {
  margin-top: 0;
  margin-bottom: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 1.5rem;
}
.step-badge {
  background: var(--contrast-color);
  color: var(--bg-color);
  width: 1.7rem;
  height: 1.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans-font);
  font-style: normal;
  font-size: 1.05rem;
  flex-shrink: 0;
}
.row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}
.seg-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0.5rem 0;
  flex-wrap: wrap;
}
.seg-name {
  width: 9rem;
  font-family: var(--sans-font);
  font-size: 1.15rem;
  color: var(--border-color);
}
label.inline {
  font-size: 1.3rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-right: 1.4rem;
}
input[type="checkbox"] {
  accent-color: var(--contrast-color);
  width: 1.3rem;
  height: 1.3rem;
}

select {
  font-family: var(--sans-font);
  font-size: 1.15rem;
  padding: 0.5rem 2.2rem 0.5rem 0.8rem;
  border: 1px solid var(--border-soft);
  border-radius: 0;
  background: var(--bg-color);
  color: var(--text-color);
  min-width: 11rem;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23a00000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
}
select.color-select option {
  background: #ffffff;
  color: #222222;
}
select:focus-visible {
  outline: none;
  border-color: var(--contrast-color);
  box-shadow: 0 0 0 3px rgba(160, 0, 0, 0.12);
}

.seg-swatch {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.mini-swatch {
  display: inline-block;
  width: 1.4rem;
  height: 1.4rem;
  border: 1px solid var(--border-soft);
}

/* ---------- 输出与按钮 ---------- */
textarea {
  width: 100%;
  height: 15rem;
  margin-top: 0.6rem;
  font-family: var(--code-font);
  font-size: 1.1rem;
  line-height: 1.7;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border-soft);
  border-radius: 0;
  background: #161616;
  color: #e8e6e3;
  resize: vertical;
}
textarea:focus-visible {
  outline: none;
  border-color: var(--contrast-color);
}
.tip {
  font-size: 1.05rem;
  color: var(--border-color);
  margin-top: 0.8rem;
  line-height: 1.8;
}

.btn {
  font-family: var(--sans-font);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  padding: 0.7rem 1.4rem;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-color);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  display: inline-block;
  text-align: center;
}
.btn:hover {
  color: var(--contrast-color);
  border-color: var(--contrast-color);
}
.btn-danger {
  border-color: var(--contrast-color);
  color: var(--contrast-color);
}
.btn-danger:hover {
  background: rgba(160, 0, 0, 0.06);
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.2rem;
}

/* ---------- 闪烁动画（预览用） ---------- */
@keyframes blink-anim {
  50% {
    opacity: 0;
  }
}
.blink {
  animation: blink-anim 1s step-start infinite;
}

/* ---------- 打印 ---------- */
@media print {
  header.site-header,
  footer.site-footer,
  .btn-row {
    display: none;
  }
  body {
    background: #fff;
  }
}
