@font-face {
  font-family: 'Punctuation SC';
  src: local('PingFang SC'), local('Noto Sans CJK SC'), local('Noto Sans SC'), local('Heiti SC'), local('Microsoft Yahei');
  unicode-range: U+201C, U+201D, U+2018, U+2019, U+2E3A, U+2014, U+2013, U+2026, U+00B7, U+007E, U+002F; /* Unicode range for punctuation marks */
}

@font-face {
  font-family: 'Punctuation TC';
  src: local('PingFang TC'), local('Noto Sans CJK TC'), local('Noto Sans TC'), local('Heiti TC'), local('Microsoft JhengHei');
  unicode-range: U+201C, U+201D, U+2018, U+2019, U+2E3A, U+2014, U+2013, U+2026, U+00B7, U+007E, U+002F; /* Unicode range for punctuation marks */
}

/*
-apple-system: iOS Safari, macOS Safari, macOS Firefox
BlinkMacSystemFont: macOS Chrome
Segoe UI: Windows
Roboto: Android, Chrome OS
Oxygen-Sans: KDE
Fira Sans: Firefox OS
Droid Sans: Older versions of Android
Ubuntu: Ubuntu
Cantarell: GNOME
Helvetica Neue: macOS versions < 10.11
Arial: Any
PingFang TC/SC: macOS
Noto Sans CJK TC/SC: Ubuntu, Android
Noto Sans TC/SC: Ubuntu, Android
Heiti TC/SC: macOS
DengXian: Windows
Microsoft Jhenghei / Microsoft Yahei: Windows < Vista
sans-serif: Fallback
*/

[lang=zh-hant] {
  font-family: 'Punctuation TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', 'PingFang TC', 'Noto Sans CJK TC', 'Noto Sans TC', 'Heiti TC', 'Microsoft JhengHei', sans-serif;
  text-autospace: normal;

  /* For implementations that support `trim-start`, apply this value first. */
  text-spacing-trim: trim-start;
  
  /* Browsers that support trim-both will overwrite the previous line, and browsers that don't support it will ignore this line. */
  text-spacing-trim: trim-both;
}

[lang=zh-hans] {
  font-family: 'Punctuation SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', 'PingFang SC', 'Noto Sans CJK SC', 'Noto Sans SC', 'Heiti SC', 'DengXian', 'Microsoft YaHei', sans-serif;
  text-autospace: normal;

  /* For implementations that support `trim-start`, apply this value first. */
  text-spacing-trim: trim-start;
  
  /* Browsers that support trim-both will overwrite the previous line, and browsers that don't support it will ignore this line. */
  text-spacing-trim: trim-both;
}

h2 {
  margin-top: 3em;
  margin-bottom: 0em;
}

:is(.head, #abstract, #sotd) h2 {
  margin-top: 0;
}

h3 {
  margin-top: 3em;
}

h4  {
  margin-top: 2em;
  font-size: 100%;
  font-weight: normal;
  color: var(--heading-text, #005a9c);
}

h5 {
  font-style: inherit !important;
}

.leadin {
  font-weight: bold;
}

ins {
  background-color: var(--clreq-ins-bg, #99FF99);
  color: var(--clreq-control-text, black);
  text-decoration: none;
}

del {
  display: inline;
  color: silver;
}

figure {
  margin-bottom: 2em;
  text-align: center;
  vertical-align: top;
}

figure img {
  vertical-align: middle;
}

figcaption {
  text-align: center;
  margin: 0.5em 2em;
  font-style: italic;
  font-size: 90%;
}

span:lang(zh), figcaption:lang(zh) {
  font-style: normal;
}

.figno:after {
  content: ':\00A0  ';
}

a .figno:after {
  content: '';
}

a.termref:link,
a.termref:hover,
a.termref:visited,
a.termref:active {
  text-decoration:none;
  border-bottom: 1px dotted #FC0;
  color: var(--clreq-term-text, #C60);
}

.qterm:before, .qchar:before { content: "'"; }
.qterm:after, .qchar:after { content: "'"; }
.quote:before { content: '"'; }
.quote:after { content: '"'; }

code,
samp,
kbd {
  font-family: Consolas, "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", Monaco, "Courier New", monospace;
  font-size: 100%;
}

code { color: var(--clreq-code-text, #A52A2A); }


.translateme, .retranslateme {
  background-color: var(--clreq-translate-bg, #F3F3C3);
  color: var(--clreq-control-text, black);
  background-clip: content-box;
}
.checkme {
  background-color: var(--clreq-check-bg, #BBEFFC);
  color: var(--clreq-control-text, black);
  background-clip: content-box;
}

.checkme::before {
    content: ' Check this translation: ';
    color: var(--clreq-status-text, #9c3b00);
	}

.translateme::before {
    content: ' Translate this: ';
    color: var(--clreq-status-text, #9c3b00);
	}

.retranslateme::before {
    content: ' (Re)translate this: ';
    color: var(--clreq-status-text, #9c3b00);
	}

.is-multilingual [its-locale-filter-list^="zh"] {
  padding-left: .4em;
  border-left: 3px solid;
}
.is-multilingual [its-locale-filter-list="zh-hant"] {
  border-color: rgba(64,196,64,.5);
}
.is-multilingual [its-locale-filter-list="zh-hans"] {
  border-color: rgba(248,138,5,.5);
}

.is-multilingual h2[its-locale-filter-list^="zh"],
.is-multilingual h3[its-locale-filter-list^="zh"],
.is-multilingual h4[its-locale-filter-list^="zh"],
.is-multilingual h5[its-locale-filter-list^="zh"],
.is-multilingual h6[its-locale-filter-list^="zh"],
.is-multilingual p[its-locale-filter-list^="zh"],
.is-multilingual ol[its-locale-filter-list^="zh"],
.is-multilingual ul[its-locale-filter-list^="zh"] {
  margin-left: calc(-.4em - 2px);
}

.is-multilingual .secno ~ span[its-locale-filter-list^="zh"] {
  display: inline-block;
  margin-left: .3em;
  padding-left: .3em;
}

.note {
  margin-left: -1em !important;
  padding-left: 1.5em !important;
}

.note h6 {
  margin-top: 1em;
  margin-bottom: 0;
  font-weight: bold;
}

table { border-collapse: collapse; }
table tr { border-bottom: 1px solid var(--clreq-border, #ddd); }
table th { padding: .25em .25em .5em .25em; }
table th:last-child { padding-left: .5em; }
table th span { font-size: .815em; }

table td {
  padding: .75em .25em .75em .25em;
  vertical-align: top;
}

h2 + table,
table + table {
  margin-top: 1rem;
}

table thead span[its-locale-filter-list] {
  display: block;
  margin-top: .1em;
  text-align: start;
}

table thead span[its-locale-filter-list='en']:first-child { margin-top: 0; }

.is-multilingual table thead span[its-locale-filter-list='en'] {
  padding-left: calc(.4em + 3px);
}

/**
 * Table for character sizes
 */
table.charsize {
  display: inline-table;
  margin-right: 1em;
  margin-top: 0;
  font-size: 95%;
}

/**
 * Tables in appendix
 */
table.appendix {
  display: block;
  overflow-x: auto;
}
table.appendix td p { margin: .5em 0; }
table.appendix td p:first-child { margin-top: 0; }
table.appendix td p:last-child { margin-bottom: 0; }

table.appendix p[its-locale-filter-list^='zh'],
table.appendix ol[its-locale-filter-list^='zh'] { margin-left: .25em; }
table.appendix p[its-locale-filter-list='en'] { margin-left: calc(.25em + .4em + 3px); }
table.appendix ol[its-locale-filter-list='en'] { margin-left: .4em; }
table.appendix td small { display: block; }

.is-multilingual table.appendix ol,
.is-multilingual table.appendix ul { padding-left: 2em; }

/**
 * Tables of punctuation
 */
table.punctuation th.name { width: 5em; max-width: 5.5em; }
table.punctuation th.character { min-width: 2.5em; }
table.punctuation th.unicode { width: 5em; }
table.punctuation th.true-or-false { width: 10em; }
table.full.punctuation td:nth-child(4),
table.full.punctuation td:nth-child(5),
table.full.punctuation td:nth-child(6),
table.full.punctuation td:nth-child(7) {
  text-align: center;
  vertical-align: middle;
}

/**
 * Table of glossary
 */
table.glossary th.term { width: 6.25em; }
table.glossary th.term-pinyin { width: 5.25em; }
table.glossary th.term-en { width: 5.25em; }

/* Override the display property */
[its-locale-filter-list][hidden] { display: none; }

/* Search */
.input {
  display: flex;
  align-items: center;
  font-size: 16px;
  letter-spacing: normal;
  max-width: 100%;
  text-align: left;
  padding: 16px 16px 8px 16px;
  margin-top: 4px;
}

/* label {
  margin-right: 15px;
} */

#search {
  color: var(--clreq-control-text, rgba(0, 0, 0, .87));
  max-height: 40px;
  flex: 1 1 auto;
  line-height: 20px;
  padding: 8px 16px;
  max-width: 100%;
  min-width: 0;
  width: 100%;
  background-color: var(--clreq-input-bg, #f5f5f5);
  border: 1px solid var(--clreq-border, #e0e0e0);
  border-radius: 8px;
  transition: all 0.2s ease-in-out;
  font-size: 14px;
}

#search:hover {
  background-color: var(--clreq-input-hover-bg, #fafafa);
  border-color: var(--clreq-muted-text, #bdbdbd);
}

#search:focus {
  outline: none;
  background-color: var(--clreq-panel-bg, #ffffff);
  border-color: #2196f3;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

#search::placeholder {
  color: var(--clreq-muted-text, #757575);
}

.hidden {
  display: none;
}

.search-container {
  position: relative;
  margin-bottom: 20px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

#search {
  padding-right: 40px; /* Space for the clear button */
}

#clear-search {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--clreq-muted-text, #757575);
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

#clear-search:hover {
  background-color: var(--clreq-input-hover-bg, rgba(0, 0, 0, 0.1));
}

.search-results-count {
  font-size: 14px;
  color: var(--clreq-muted-text, #757575);
  padding: 0 16px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

mark {
  background-color: var(--clreq-mark-bg, #ffeb3b);
  color: var(--clreq-control-text, black);
  padding: 0 2px;
  border-radius: 2px;
}

section li[id] {
  position: relative;
}

section li[id] > a.self-link {
  color: inherit;
  position: absolute;
  left: -2.5em;
  font-size: 1rem;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

section li[id]:hover > a.self-link {
  opacity: .5;
}

section li[id] > a.self-link::before {
  content: "§";
  text-decoration: none;
  color: inherit;
}




#langSwitch {
	position: fixed;
	/*top: -14px;*/
	z-index: 10000;
	top: 160px;
	right: 10px;
	width: 8em;
	text-align: right;
    display: flex;
    flex-direction: column;
    align-content: end;
    background-color: var(--clreq-panel-bg, white);
    color: var(--clreq-control-text, black);
    padding:1em;
    border-radius: .75em;
	}
/* Tablets (portrait) */
@media (max-width: 900px) {
    #langSwitch {
        width: 6em;
        padding-block-start: .25em;
        padding-block-end: 1em;
        padding-inline: .75em;
        margin: 0;
        top: auto;
        bottom:0;
        }
    }

/* Mobile phones */
@media (max-width: 600px) {
    #langSwitch {
        width: 5em;
        padding-block-end: .5em;
        }
    }

#langSwitch button {
	background: var(--clreq-panel-bg, #FFF) none repeat scroll 0% 0%;
	color: inherit;
	border: 1px solid var(--clreq-border, #CCC);
	border-radius: 5px;
    display: block;
    margin-block: .2em;
	}
#langSwitch button:lang(zh-hans) {
	background-color: var(--clreq-hans-bg, #fbc481);
	}

#langSwitch button:lang(zh-hant) {
	background-color: var(--clreq-hant-bg, #9fe19f);
	}

.selectedLanguage::before {
    content: '→';
    margin-inline-end:.3em;
    font-size: 1em;
    text-align: center;
    }
#languageChoiceLabel {
    font-size: 70%;
    display: block;
    align-self: center;
    }

/* Match both the system preference and ReSpec's manual dark-mode toggle.
 * Respect the manual light override; keep these palettes in sync.
 * Screen-only rules preserve print colors. */
@media screen and (prefers-color-scheme: dark) {
  body:not(:has(input[name="color-scheme"][value="light"]:checked)) {
    --clreq-ins-bg: #173b24;
    --clreq-term-text: #ffbb77;
    --clreq-code-text: #ffaaaa;
    --clreq-translate-bg: #343419;
    --clreq-check-bg: #153943;
    --clreq-status-text: #ffb38a;
    --clreq-control-text: #ddd;
    --clreq-panel-bg: #181818;
    --clreq-input-bg: #222;
    --clreq-input-hover-bg: #303030;
    --clreq-border: #666;
    --clreq-muted-text: #aaa;
    --clreq-mark-bg: #514600;
    --clreq-hans-bg: #503416;
    --clreq-hant-bg: #234323;
  }
}

@media screen {
  body.darkmode {
    --clreq-ins-bg: #173b24;
    --clreq-term-text: #ffbb77;
    --clreq-code-text: #ffaaaa;
    --clreq-translate-bg: #343419;
    --clreq-check-bg: #153943;
    --clreq-status-text: #ffb38a;
    --clreq-control-text: #ddd;
    --clreq-panel-bg: #181818;
    --clreq-input-bg: #222;
    --clreq-input-hover-bg: #303030;
    --clreq-border: #666;
    --clreq-muted-text: #aaa;
    --clreq-mark-bg: #514600;
    --clreq-hans-bg: #503416;
    --clreq-hant-bg: #234323;
  }
}
