/* trinbrasil.com: the company's record as a two-party memorandum on a signing table. */

@font-face {
  font-family: "Libre Caslon Text";
  src: url("fonts/libre-caslon-text-normal-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Libre Caslon Text";
  src: url("fonts/libre-caslon-text-italic-400.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Libre Caslon Text";
  src: url("fonts/libre-caslon-text-normal-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Public Sans";
  src: url("fonts/public-sans-normal-400-700.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* The table and the sheet */
  --table: #1d4e4f;
  --table-ink: #e8f1f0;
  --sheet: #ffffff;
  --ink: #16191c;
  --ink-2: #3a4649;

  /* The fixed colour language: one colour, one meaning */
  --tt: #b8081a;      /* Trinidad and Tobago (wordmark red) */
  --br: #006000;      /* Brazil (wordmark green) */
  --between: #0870b8; /* what lies between (rule blue) */

  /* The macaw's own stripes, for the ribbon */
  --m-blue: #0870b8;
  --m-green: #089040;
  --m-yellow: #f8f000;
  --m-red: #e81820;
  --m-black: #0c0c0c;

  --sticker: #f8e000;

  --serif: "Libre Caslon Text", Georgia, "Times New Roman", serif;
  --sans: "Public Sans", "Helvetica Neue", Arial, sans-serif;

  --u: 0.5rem;            /* 8px base unit */
  --sheet-w: 55rem;
  --margin-l: calc(var(--u) * 15);
  --margin-r: calc(var(--u) * 12);

  color-scheme: light;
  accent-color: var(--between);
  scrollbar-color: var(--table-ink) var(--table);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background-color: var(--table);
  /* fine baize grain */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--m-yellow); color: var(--ink); }

img, svg { display: block; max-width: 100%; }

a { color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
:focus-visible { outline: 3px solid var(--between); outline-offset: 3px; }

.skip {
  position: absolute;
  left: calc(var(--u) * 2);
  top: calc(var(--u) * 2);
  z-index: 20;
  padding: var(--u) calc(var(--u) * 2);
  background: var(--sheet);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1rem;
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

/* ---------- The table and the sheet ---------- */

.table {
  padding: calc(var(--u) * 6) calc(var(--u) * 4) calc(var(--u) * 8);
}

.sheet {
  position: relative;
  max-width: var(--sheet-w);
  margin: 0 auto;
  padding: calc(var(--u) * 6) var(--margin-r) calc(var(--u) * 10) var(--margin-l);
  background: var(--sheet);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.18), 0 18px 40px -8px rgba(0, 0, 0, 0.45);
}

/* Binding ribbon: the macaw's five stripes, down the left margin from under the seal. */
.ribbon {
  position: absolute;
  left: calc(var(--u) * 5);
  top: calc(var(--u) * 6);
  bottom: calc(var(--u) * -4);
  width: calc(var(--u) * 4);
  display: flex;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - var(--u) * 2), 0 100%);
}
.ribbon i { flex: 1; }
.ribbon i:nth-child(1) { background: var(--m-blue); }
.ribbon i:nth-child(2) { background: var(--m-green); }
.ribbon i:nth-child(3) { background: var(--m-yellow); }
.ribbon i:nth-child(4) { background: var(--m-red); }
.ribbon i:nth-child(5) { background: var(--m-black); }

@media (prefers-reduced-motion: no-preference) {
  .ribbon i { animation: unfurl 1.5s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both; }
  .ribbon i:nth-child(2) { animation-delay: 0.32s; }
  .ribbon i:nth-child(3) { animation-delay: 0.44s; }
  .ribbon i:nth-child(4) { animation-delay: 0.56s; }
  .ribbon i:nth-child(5) { animation-delay: 0.68s; }
}
/* reveal one viewport's length (the part a reader sees), then release the rest */
@keyframes unfurl {
  0% { clip-path: inset(0 0 100% 0); }
  96% { clip-path: inset(0 0 calc(100% - 100vh) 0); }
  100% { clip-path: inset(0 0 0 0); }
}

/* The seal: serrated, in the colour of what lies between, framing the macaw. */
.seal {
  position: absolute;
  left: calc(var(--u) * -3);
  top: calc(var(--u) * -3);
  width: calc(var(--u) * 17);
  height: calc(var(--u) * 17);
  z-index: 2;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.3));
}
.seal svg { width: 100%; height: 100%; }
.seal-edge { fill: var(--between); }
.seal-ring { fill: none; stroke: var(--sheet); stroke-width: 1.2; }
.seal-text { fill: var(--sheet); font-family: var(--sans); font-weight: 700; font-size: 8.4px; letter-spacing: 0.08em; }
.seal-face { fill: var(--sheet); }
.seal-macaw {
  position: absolute;
  left: 50%;
  top: 50%;
  /* window onto the macaw alone: x 24–78, y 16–85 of the 330×100 logo */
  width: 52px;
  height: 66px;
  transform: translate(-50%, -50%);
  background: url("photos/logo-original.png") -23px -15px / 314px 95px no-repeat;
}

/* ---------- Letterhead and parties ---------- */

.letterhead { padding-top: calc(var(--u) * 2); }
/* the logo's own 24px transparent margin is pulled back so the macaw aligns with the text */
.logo { width: 330px; height: auto; margin: 0 0 calc(var(--u) * 5) -24px; }

h1 {
  margin: 0;
  font-weight: 400;
  font-size: clamp(2.5rem, 1.6rem + 2.6vw, 3.75rem);
  line-height: 1.04;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.subtitle {
  margin: calc(var(--u) * 1.5) 0 0;
  font-style: italic;
  font-size: clamp(1.375rem, 1.1rem + 0.9vw, 1.875rem);
  line-height: 1.25;
  color: var(--between);
}

.parties {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: calc(var(--u) * 6);
  margin-top: calc(var(--u) * 7);
}
/* signature block: blank signing space, the party's rule, the printed name, the capacity */
.party { padding-top: calc(var(--u) * 6); }
.party-name { border-top: 3px solid var(--party-colour); padding-top: var(--u); }
.party-tt, .office-tt { --party-colour: var(--tt); }
.party-br, .office-br { --party-colour: var(--br); }
.party p, .office p { margin: 0; }
.party-country { color: var(--party-colour); font-weight: 600; }
.party-name { font-size: 1.625rem; line-height: 1.3; }
.party-role { font-family: var(--sans); font-size: 0.9375rem; color: var(--ink-2); margin-top: calc(var(--u) * 0.5); }

/* ---------- Clauses ---------- */

.clause, .exhibits { scroll-margin-top: calc(var(--u) * 4); }

.sheet h2 {
  display: flex;
  align-items: baseline;
  gap: calc(var(--u) * 2);
  margin: calc(var(--u) * 10) 0 calc(var(--u) * 3);
  font-weight: 400;
  font-size: clamp(1.875rem, 1.4rem + 1.3vw, 2.5rem);
  line-height: 1.1;
}
.clause-n {
  flex: none;
  min-width: calc(var(--u) * 5);
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.6em;
  color: var(--between);
}

.clause-lead { margin: 0 0 calc(var(--u) * 2); }
.subclauses { list-style: none; margin: 0; padding: 0; max-width: 36em; }
.subclauses li {
  display: grid;
  grid-template-columns: calc(var(--u) * 7) minmax(0, 1fr);
  margin-bottom: calc(var(--u) * 2);
}
.subclauses p { margin: 0; text-wrap: pretty; }
.sub-n {
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 2.1;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.subclauses strong { font-weight: 700; }

.motto {
  margin: calc(var(--u) * 5) 0 0 calc(var(--u) * 7);
  padding: calc(var(--u) * 3) 0;
  border-block: 1px solid var(--between);
  max-width: 32em;
}
.motto p { margin: 0; font-style: italic; font-size: clamp(1.375rem, 1.1rem + 0.8vw, 1.75rem); line-height: 1.35; }
.motto footer {
  margin-top: calc(var(--u) * 1.5);
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-2);
}

.offices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: calc(var(--u) * 6);
  margin: 0 0 calc(var(--u) * 4);
}
.office { padding-top: calc(var(--u) * 2); position: relative; border-top: 3px solid var(--party-colour); }
.office .office-name { font-size: 1.375rem; }
.office .party-country { font-weight: 400; }
.office p { text-wrap: balance; }

/* ---------- Exhibits: photographs with exhibit stickers ---------- */

.exhibits h2 { justify-content: flex-start; }
.exhibit { margin: 0 0 calc(var(--u) * 6); }
.plate { position: relative; max-width: 468px; }
.exhibit img { width: 100%; height: auto; border: 1px solid var(--ink); }
.exhibit figcaption {
  margin-top: calc(var(--u) * 1.5);
  font-size: 1.0625rem;
  line-height: 1.5;
}
@media (min-width: 64rem) {
  /* the caption column borrows the sheet's right margin so captions run ~25 characters a line */
  .exhibit {
    display: grid;
    grid-template-columns: 468px minmax(0, 1fr);
    gap: calc(var(--u) * 4);
    align-items: start;
    margin-right: calc(var(--margin-r) * -1 + var(--u) * 6);
  }
  .exhibit figcaption { margin-top: 0; padding-top: var(--u); border-top: 1px solid var(--ink); }
  .exhibit-label { display: block; margin-bottom: calc(var(--u) * 0.5); }
}
.exhibit-label { font-family: var(--sans); font-weight: 700; font-size: 0.875rem; letter-spacing: 0.06em; }
.sticker {
  position: absolute;
  right: calc(var(--u) * -3);
  top: calc(var(--u) * 2);
  z-index: 1;
  display: grid;
  place-items: center;
  width: calc(var(--u) * 10);
  padding: var(--u) 0 calc(var(--u) * 1.25);
  background: var(--sticker);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1.75rem;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transform: rotate(3deg);
}
.sticker b { font-size: 0.625rem; letter-spacing: 0.16em; text-transform: uppercase; margin-bottom: calc(var(--u) * 0.5); }

/* ---------- Index tabs: clauses white, exhibits yellow; the current one pulled out ---------- */

.tabs {
  position: fixed;
  z-index: 10;
  top: calc(var(--u) * 14);
  left: calc(50% + var(--sheet-w) / 2);
}
.tabs ol { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--u); }
.tabs a {
  display: flex;
  align-items: baseline;
  gap: var(--u);
  width: calc(var(--u) * 17);
  min-height: calc(var(--u) * 5.5);
  padding: var(--u) calc(var(--u) * 2) var(--u) calc(var(--u) * 1.5);
  background: var(--sheet);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transform: translateX(calc(var(--u) * -2.5));
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.tabs .tab-exhibit a { background: var(--sticker); }
.tab-n { font-size: 0.75rem; font-weight: 700; color: var(--between); min-width: calc(var(--u) * 3.5); font-variant-numeric: tabular-nums; }
.tabs .tab-exhibit .tab-n { color: var(--ink); }
.tabs a:hover { transform: translateX(calc(var(--u) * -1)); }
.tabs a[aria-current="true"] { transform: translateX(var(--u)); font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .tabs a { transition: none; } }

/* ---------- Colophon on the table ---------- */

.colophon {
  max-width: var(--sheet-w);
  margin: 0 auto;
  background: var(--table);
  padding: 0 calc(var(--u) * 4) calc(var(--u) * 8);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--u) calc(var(--u) * 4);
  color: var(--table-ink);
  font-family: var(--sans);
  font-size: 0.9375rem;
}
.colophon p { margin: 0; }

/* ---------- Narrower desktops: tabs tuck into the sheet's right margin ---------- */

@media (min-width: 64rem) and (max-width: 79.99rem) {
  .tabs a { width: auto; min-width: calc(var(--u) * 6); justify-content: center; padding-inline: var(--u); }
  .tabs .tab-n { min-width: 0; font-size: 0.875rem; }
  .tabs .tab-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
}

/* ---------- Tablet and phone: the tabs become a sticky strip on the table ---------- */

@media (max-width: 63.99rem) {
  :root { --margin-l: calc(var(--u) * 11); --margin-r: calc(var(--u) * 5); }
  .tabs {
    position: sticky;
    top: 0;
    left: auto;
    right: auto;
    padding: var(--u) calc(var(--u) * 2);
    background: var(--table);
    border-bottom: 1px solid rgba(0, 0, 0, 0.35);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs ol { display: flex; gap: var(--u); width: max-content; }
  .tabs a {
    width: auto;
    min-height: calc(var(--u) * 5.5);
    align-items: center;
    padding: var(--u) calc(var(--u) * 1.5);
    transform: none;
    box-shadow: none;
  }
  .tabs a:hover { transform: none; }
  .tabs a[aria-current="true"] { transform: translateY(2px); box-shadow: inset 0 -3px 0 var(--between); }
  .clause, .exhibits { scroll-margin-top: calc(var(--u) * 10); }
  .table { padding: calc(var(--u) * 5) calc(var(--u) * 2) calc(var(--u) * 6); }
}

@media (max-width: 45.99rem) {
  :root { --margin-l: calc(var(--u) * 6); --margin-r: calc(var(--u) * 2.5); }
  body { font-size: 1.125rem; }
  .sheet { padding-top: calc(var(--u) * 12); }
  .ribbon { left: calc(var(--u) * 2); width: calc(var(--u) * 2); top: calc(var(--u) * 9); }
  .seal { left: calc(var(--u) * -1); top: calc(var(--u) * -2); width: calc(var(--u) * 13); height: calc(var(--u) * 13); }
  .seal-macaw { width: 41px; height: 52px; background-position: -18px -12px; background-size: 248px 75px; }
  .logo { width: 231px; margin-left: -17px; }
  .tabs ol { width: auto; }
  .tabs a { padding: var(--u) calc(var(--u) * 1.75); }
  .tabs .tab-n { min-width: 0; font-size: 0.875rem; }
  .tabs a:not([aria-current="true"]) .tab-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .parties, .offices { grid-template-columns: minmax(0, 1fr); gap: calc(var(--u) * 4); }
  .subclauses li { grid-template-columns: calc(var(--u) * 5.5) minmax(0, 1fr); }
  .motto { margin-left: 0; }
  .sticker { right: calc(var(--u) * -1); top: calc(var(--u) * -2); width: calc(var(--u) * 8); font-size: 1.375rem; }
  .colophon { flex-direction: column; padding: 0 calc(var(--u) * 2) calc(var(--u) * 6); }
}

@media print {
  body { background: none; }
  .tabs, .ribbon, .skip { display: none; }
  .sheet { box-shadow: none; }
}
