@font-face {
  font-family: "NotoSans";
  src: url("fonts/sans_serif/noto/noto.ttf") format("truetype");
}

@font-face {
  font-family: "NotoSerif";
  src: url("fonts/serif/NotoSerif.ttf") format("truetype");
}

@font-face {
  font-family: "NotoMono";
  src: url("fonts/serif/NotoMono.ttf") format("truetype");
}

@font-face {
  font-family: "DM";
  src: url("fonts/DM.ttf") format("truetype");
}

@font-face {
  font-family: "chart";
  src: url("fonts/Charter/charter_regular.woff2") format("woff2");
}

:root {
  --bg: #ffffff;
  --muted: #e0e4e6;
  --text: #222222;
  --subtext: #444444;
  --border: #d6d6d6;
  --accent: #333333;
  --surface-alt: #f6f7f8;
  --max-width: 900px;
  --nav-width: 1100px;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.07);
  --page-gutter: clamp(1rem, 3vw, 2rem);
  --article-block-space: 2vh;
}

/* ---------- Base ---------- */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "chart", serif;
  line-height: 1.65;
  transition: opacity 140ms ease;
}

body.i18n-fade-out {
  opacity: 0.15;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

svg {
  flex: 0 0 auto;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

p,
li {
  margin: 0 0 1rem;
  color: var(--subtext);
  font-family: "NotoSerif", serif;
  font-size: 20px;
  font-weight: 350;
  line-height: 1.5;
  -webkit-hyphens: auto;
  -moz-hyphens: auto;
  -ms-hyphens: auto;
  hyphens: auto;
}

li {
  line-height: 1.4;
}

h1,
h2,
h3,
h4,
h5,
h6,
.title,
.container h1,
.container h2 {
  font-family: "DM", sans-serif;
}

.caption {
  font-size: small;
}

.crynodeb {
  margin: 0 0 1rem;
  color: var(--subtext);
  font-family: "DM", sans-serif;
  font-size: 23px;
  font-weight: 300;
  line-height: 1.3;
}

.awdur,
.ael,
.tadogaeth {
  font-family: "DM", sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.2;
}

.text {
  font-family: "chart", serif;
  text-align: justify;
  text-wrap: pretty;
}

.text,
.quote,
.footnote,
p,
li {
  overflow-wrap: break-word;
}

/* ---------- Hyperlinks ---------- */
.container p a,
.container li a,
.rhagymadrodd p a,
.rhagymadrodd li a,
.penllun p a,
.penllun li a {
  color: #1f5fbf;
  text-decoration: none;
  font-weight: 500;
  position: relative;
  z-index: 0;
  transition: color 0.2s ease;
}

/* soft underline/highlight */
.container p a::after,
.container li a::after,
.rhagymadrodd p a::after,
.rhagymadrodd li a::after,
.penllun p a::after,
.penllun li a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.08em;
  height: 0.32em;
  background: rgba(70, 130, 220, 0.18);
  border-radius: 0.08em;
  z-index: -1;
  transition:
    height 0.2s ease,
    bottom 0.2s ease,
    background 0.2s ease;
}

/* hover */
.container p a:hover,
.container li a:hover,
.rhagymadrodd p a:hover,
.rhagymadrodd li a:hover,
.penllun p a:hover,
.penllun li a:hover {
  color: #124a9c;
  text-decoration: none;
}

.container p a:hover::after,
.container li a:hover::after,
.rhagymadrodd p a:hover::after,
.rhagymadrodd li a:hover::after,
.penllun p a:hover::after,
.penllun li a:hover::after {
  height: 0.9em;
  bottom: -0.05em;
  background: rgba(70, 130, 220, 0.26);
}

/* ---------- Shared layout containers ---------- */
.container,
.rhagymadrodd,
.penllun,
.containerGrey {
  width: 100%;
}

.container,
.containerGrey {
  max-width: calc(var(--max-width) + (2 * var(--page-gutter)));
  margin-inline: auto;
  padding-inline: var(--page-gutter);
}

.container {
  padding-top: var(--article-block-space);
  padding-bottom: var(--article-block-space);
}

.containerGrey {
  display: block;
  padding-top: var(--article-block-space);
  padding-bottom: var(--article-block-space);
  background-color: var(--surface-alt) !important;
}

.rhagymadrodd,
.penllun {
  padding-top: 1vh;
  padding-bottom: 1vh;
}

/* ---------- Top nav ---------- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: var(--accent);
  color: #d6d6d6;
  font-family: "DM", sans-serif;
  backdrop-filter: blur(10px);
}

.topnav .inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  max-width: calc(var(--nav-width) + (2 * var(--page-gutter)));
  padding-top: 10px;
  padding-bottom: 10px;
}

.topnav .icons {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topnav .icons a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 999px;
}

.topnav .icons a:hover {
  background: rgba(0, 0, 0, 0.06);
  text-decoration: none;
}

.separator {
  padding: 0 6px;
  font-size: 20px;
  opacity: 0.4;
}

/* ---------- Hero ---------- */
.hero {
  border-bottom: 1px solid var(--border);
  background: var(--muted);
}

.hero .wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 26px;
  align-items: center;
  padding-top: 34px;
  padding-bottom: 34px;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(2.1rem, 3.8vw, 3.5rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.hero .meta {
  margin: 0 0 14px;
  color: var(--subtext);
  font-size: 0.98rem;
}

.hero .lead {
  margin-bottom: 18px;
  font-size: 1.05rem;
}

.hero .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- Bibliography ---------- */
.bibliography {
  padding: 5rem 0;
  border-top: 1px solid var(--border);
  background: #d2dadf;
}

.bibliography-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem 8vw;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.45);
}

.bibliography h1 {
  margin: 0 0 2rem;
  color: var(--text);
  font-family: "DM", sans-serif;
  font-size: clamp(2rem, 3vw, 2.8rem);
  font-weight: 400;
  letter-spacing: -0.02em;
}

.bibliography h2 {
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid #cfcfcf;
  color: #333333;
  font-family: "DM", sans-serif;
  font-size: 1.2rem;
  font-weight: 400;
}

.bib-entry {
  margin: 0 0 0.9rem;
  padding-left: 2em;
  color: var(--subtext);
  font-family: "NotoSerif", serif;
  font-size: 1.05rem;
  line-height: 1.6;
  text-indent: -2em;
}

.bib-entry em {
  font-style: italic;
}

/* ---------- Article typography ---------- */
.quote {
  margin: 1.5rem 0 1.5rem 3rem;
  padding-left: 1.25rem;
  border-left: 3px solid #c7c7c7;
  color: #333333;
  font-family: "chart", serif;
  font-size: 1.05rem;
  line-height: 1.7;
}

.footnote {
  margin: 0 0 0.4rem;
  padding-left: 1.6em;
  color: var(--subtext);
  font-size: 0.85rem;
  line-height: 1.4;
  text-indent: -1.6em;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  padding: 0.75em 1em;
  border-radius: 10px;
  background-color: #ececec;
  color: #353535;
  font-family: "Poppins", sans-serif;
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 0.075em;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.55);
  text-decoration: none;
}

.btn.primary {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Sections ---------- */
.section {
  padding: 34px 0;
}

.section h2 {
  margin: 0 0 18px;
  color: var(--text);
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}

/* ---------- Cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
  text-align: center;
}

.card .thumb {
  width: min(220px, 60%);
  margin: 0 auto 12px;
}

.card h3 {
  margin: 0 0 8px;
  text-align: center;
}

.card p {
  margin: 0 0 12px;
}

.card .cta {
  display: flex;
  justify-content: center;
}

/* ---------- Footer ---------- */
footer {
  padding: 18px 0;
  border-top: 1px solid var(--border);
  color: var(--subtext);
  font-size: 0.95rem;
}

/* ---------- Tables ---------- */
.table-wrapper {
  overflow: auto;
  padding-bottom: 1vh;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.table-wrapper::-webkit-scrollbar {
  width: 0;
  height: 0;
}

table {
  width: 100%;
  margin: 0.5vh 0;
  font-family: "Poppins", sans-serif;
  border-collapse: collapse;
}

table a {
  font-size: inherit;
}

table th,
table td {
  font-size: 85%;
}

table th b,
table td b {
  font-weight: 900;
}

table thead {
  font-weight: 700;
}

table tbody tr {
  border-right: 0;
  border-left: 0;
  border-top: solid 1px #ffffff;
  border-bottom: solid 1px #ffffff;
}

table tbody tr:nth-child(2n + 1) {
  background-color: #ececec;
}

table tbody tr:first-child {
  border-top: solid 2px #ffffff;
}

table tbody tr:last-child {
  border-bottom: solid 2px #ffffff;
}

table tbody tr td.gray {
  background-color: #ececec !important;
}

table tbody tr td.nogray {
  background-color: #f6f6f6 !important;
}

table tbody.center td,
table thead.center th {
  text-align: center;
}

table td {
  padding: 0.5em;
  color: #353535;
}

table th {
  padding: 0 0.5em 0.25em;
  color: #666667;
  text-align: left;
}

table tfoot {
  border-top: solid 2px #ffffff;
}

table.alt {
  border-collapse: separate;
}

table.alt tbody tr td {
  border: solid 1px #ffffff;
  border-top-width: 0;
  border-left-width: 0;
}

table.alt tbody tr td:first-child {
  border-left-width: 1px;
}

table.alt tbody tr:first-child td {
  border-top-width: 1px;
}

table.alt thead,
table.alt tfoot {
  border-top: 0;
  border-bottom: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .hero .wrap {
    grid-template-columns: 1fr;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .container,
  .containerGrey {
    max-width: 100%;
  }

  .topnav .inner {
    justify-content: center;
  }
}

@media (max-width: 700px) {
  :root {
    --page-gutter: 1rem;
  }

  p,
  li {
    font-size: 1rem;
  }

  .bibliography {
    padding: 3rem 0;
  }

  .bibliography-inner {
    padding: 2rem 6vw;
  }

  .bib-entry {
    font-size: 1rem;
  }

  .topnav .inner {
    gap: 8px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .topnav .icons {
    justify-content: center;
  }

  .hero .wrap {
    gap: 18px;
    padding-top: 24px;
    padding-bottom: 24px;
  }

  .hero h1 {
    font-size: clamp(1.8rem, 8vw, 2.4rem);
  }

  .quote {
    margin-left: 0.75rem;
    padding-left: 0.9rem;
  }
  .penllun {
    display: none;
  }

  .hero .wrap {
    grid-template-columns: 1fr;
  }
}
}
