/* calculemus.ee — one stylesheet for both pages.
   World: a façade of honed grey Tallinn limestone laid in courses. Letters are
   V-cut into the stone in an inscriptional face (the SVG filters in each
   page, one per size so the cut stays in proportion), one cast-bronze door
   plate carries the action, and a dark granite plinth holds the legal facts.
   Three materials only: stone, cut shadow, bronze. */

@font-face {
  font-family: 'Marcellus';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/marcellus-400-latin.woff2') format('woff2');
}

@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/public-sans-latin.woff2') format('woff2');
}

:root {
  /* limestone */
  --stone: #c8c8c0;
  --stone-light: #d0d0c9;
  --stone-dark: #bcbcb2;
  --joint: #9a998f;
  --joint-lit: #dcdcd5;
  /* lettering cut into the stone */
  --cut-display: #5e5e56;
  --cut: #45463f;
  --ink: #2b2c27;
  --ink-quiet: #50514a;
  /* granite plinth */
  --granite: #35373a;
  --granite-joint: #232427;
  --granite-cut: #d2d3cf;
  --granite-quiet: #a9aba7;
  /* bronze: the door plate and nothing else */
  --bronze-hi: #7a5c36;
  --bronze: #6f5230;
  --bronze-lo: #573f24;
  --bronze-edge: #45321b;
  --bronze-cut: #f6ebd3;

  --display: 'Marcellus', 'Iowan Old Style', Georgia, serif;
  --text: 'Public Sans', ui-sans-serif, system-ui, sans-serif;
  --gutter: clamp(1.25rem, 5vw, 4.5rem);
  --measure: 88rem;
  --unit: 0.75rem; /* every course height and padding is a multiple of this */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Honed limestone: faint horizontal bedding, fine grain, sparse fossil
     flecks. Each filter region is the tile itself, so the tile stitches. */
  --limestone: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='640'%3E%3Cfilter id='m' x='0' y='0' width='1' height='1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.0047 .061' numOctaves='5' seed='23' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .24 0 0 0 0 .24 0 0 0 0 .21 0 0 0 .16 -.05'/%3E%3C/filter%3E%3Cfilter id='g' x='0' y='0' width='1' height='1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.86' numOctaves='2' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .2 0 0 0 0 .2 0 0 0 0 .18 0 0 0 .34 -.08'/%3E%3C/filter%3E%3Cfilter id='f' x='0' y='0' width='1' height='1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.31' numOctaves='1' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .32 0 0 0 0 .32 0 0 0 0 .29 0 0 0 7 -4.8'/%3E%3C/filter%3E%3Crect width='640' height='640' filter='url(%23m)'/%3E%3Crect width='640' height='640' filter='url(%23g)'/%3E%3Crect width='640' height='640' filter='url(%23f)'/%3E%3C/svg%3E");
  /* Granite: dark ground with light and dark crystals. */
  --granite-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='480' height='480'%3E%3Cfilter id='l' x='0' y='0' width='1' height='1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='2' seed='5' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .86 0 0 0 0 .86 0 0 0 0 .84 0 0 0 5 -3.05'/%3E%3C/filter%3E%3Cfilter id='d' x='0' y='0' width='1' height='1'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.42' numOctaves='2' seed='21' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .05 0 0 0 0 .05 0 0 0 0 .06 0 0 0 4 -2.2'/%3E%3C/filter%3E%3Crect width='480' height='480' filter='url(%23d)'/%3E%3Crect width='480' height='480' filter='url(%23l)' opacity='.5'/%3E%3C/svg%3E");

  color-scheme: light;
  scrollbar-color: var(--joint) var(--stone);
}

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

html {
  background: var(--granite) var(--granite-grain);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--text);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--stone) var(--limestone);
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--bronze);
  color: var(--bronze-cut);
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 4px;
}

.defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---- the façade: courses of stone ------------------------------------------ */

.facade {
  position: relative;
  isolation: isolate;
}

/* Raking daylight: on load a band of low sun sweeps across the wall from the
   left, then the wall holds its resting light (brightest top left). The
   overlay is three walls wide; the visible third slides from the dark end,
   past the band, to the resting light. Content is never hidden by it. */
.facade::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    100deg,
    rgb(255 253 246 / 0.34) 0%,
    rgb(255 253 246 / 0.12) 10%,
    rgb(255 253 246 / 0) 18.3%,
    rgb(24 24 20 / 0.1) 33.3%,
    rgb(24 24 20 / 0) 40%,
    rgb(255 250 236 / 0) 42%,
    rgb(255 250 236 / 0.75) 50%,
    rgb(255 250 236 / 0) 58%,
    rgb(24 24 20 / 0.12) 66.7%,
    rgb(24 24 20 / 0.12) 100%
  );
  background-size: 300% 100%;
  background-position: 0 0;
  mix-blend-mode: soft-light;
  animation: daylight 2.6s cubic-bezier(0.3, 0, 0.25, 1) 0.1s both;
}

@keyframes daylight {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: 0 0;
  }
}

/* A course is one row of stones. Its top edge is a mortar joint: a recessed
   dark line with the lit lip of the stone below it. */
.course {
  position: relative;
  margin: 0;
  border-top: 2px solid var(--joint);
  box-shadow: inset 0 1px 0 var(--joint-lit);
}

.course-inner {
  width: min(100% - 2 * var(--gutter), var(--measure));
  margin-inline: auto;
}

/* Stones in a course: each block is its own stone, of its own shade. */
.block {
  position: relative;
  background: var(--stone) var(--limestone);
}

.block + .block {
  border-left: 2px solid var(--joint);
  box-shadow: inset 1px 0 0 var(--joint-lit);
}

.block:nth-child(2) {
  background-color: var(--stone-dark);
  background-position: 211px 97px;
}

.block:nth-child(3) {
  background-color: var(--stone-light);
  background-position: 403px 331px;
}

/* ---- top course ----------------------------------------------------------- */

.course--top {
  border-top: 0;
  box-shadow: none;
  background: var(--stone-light) var(--limestone);
  background-position: 120px 40px;
}

.course--top::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 57%;
  width: 2px;
  background: var(--joint);
  box-shadow: 1px 0 0 var(--joint-lit);
}

.course--top .course-inner {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-block: calc(var(--unit) * 2);
  font-family: var(--text);
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cut);
  text-shadow: 0 1px 0 rgb(255 255 255 / 0.5);
}

.top-home {
  text-decoration: none;
}

.top-home:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.35em;
}

/* ---- the frieze: the name at façade scale ---------------------------------- */

.course--frieze {
  background: var(--stone) var(--limestone);
  background-position: 37px 260px;
}

.course--frieze .course-inner {
  padding-block: calc(var(--unit) * 6) calc(var(--unit) * 5);
}

.name {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  /* "CALCULEMUS OÜ" set at 0.1em tracking is 9.4em wide: fill the measure. */
  font-size: min(8.5rem, (min(100vw, var(--measure) + 2 * var(--gutter)) - 2 * var(--gutter)) / 9.5);
  line-height: 1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--cut-display);
  filter: url(#cut-xl);
}

/* ---- the motto and the door plate ---------------------------------------- */

.course--motto {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.block--motto {
  padding: calc(var(--unit) * 5) var(--gutter) calc(var(--unit) * 6);
  padding-left: max(var(--gutter), (100vw - var(--measure)) / 2);
}

.motto {
  margin: 0;
  font-family: var(--display);
  color: var(--cut);
}

.motto span {
  display: block;
}

.motto-lead {
  font-weight: 400;
  font-size: clamp(2rem, 1.15rem + 2.6vw, 3.5rem);
  line-height: 1.05;
  letter-spacing: 0.005em;
  color: var(--cut-display);
  filter: url(#cut-lg);
  margin-bottom: calc(var(--unit) * 2);
}

.motto-line {
  font-weight: 400;
  font-size: clamp(1.25rem, 0.95rem + 0.95vw, 1.875rem);
  line-height: 1.4;
  letter-spacing: 0.01em;
  filter: url(#cut-md);
}

.block--door {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--unit) * 5) var(--gutter);
  padding-right: max(var(--gutter), (100vw - var(--measure)) / 2);
}

/* The door plate: cast bronze standing a few millimetres off the stone,
   fixed with four screws, its letters engraved down to bright metal. */
.plate {
  --screw: radial-gradient(circle, #caa877 0 1.5px, #7c5d34 2px, #3a2a14 3px, transparent 3.6px);
  display: grid;
  gap: calc(var(--unit) * 1);
  width: 25rem;
  max-width: 100%;
  padding: calc(var(--unit) * 3) calc(var(--unit) * 3.5);
  text-decoration: none;
  color: var(--bronze-cut);
  background:
    var(--screw) 0.7rem 0.7rem / 0.5rem 0.5rem no-repeat,
    var(--screw) calc(100% - 0.7rem) 0.7rem / 0.5rem 0.5rem no-repeat,
    var(--screw) 0.7rem calc(100% - 0.7rem) / 0.5rem 0.5rem no-repeat,
    var(--screw) calc(100% - 0.7rem) calc(100% - 0.7rem) / 0.5rem 0.5rem no-repeat,
    linear-gradient(168deg, var(--bronze-hi), var(--bronze) 48%, var(--bronze-lo));
  border: 1px solid var(--bronze-edge);
  box-shadow:
    inset 0 1px 0 rgb(255 232 190 / 0.35),
    0 0.15rem 0.2rem rgb(20 16 8 / 0.3),
    0 0.9rem 1.6rem -0.6rem rgb(20 16 8 / 0.45);
  transition:
    filter 0.25s var(--ease-out),
    box-shadow 0.25s var(--ease-out),
    translate 0.12s var(--ease-out);
}

.plate-label {
  font-family: var(--text);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-shadow: 0 -1px 0 rgb(30 20 8 / 0.6);
}

.plate-address {
  font-family: var(--text);
  font-weight: 600;
  font-size: clamp(1.25rem, 1rem + 0.7vw, 1.625rem);
  line-height: 1.2;
  letter-spacing: 0.01em;
  text-shadow: 0 -1px 0 rgb(30 20 8 / 0.7);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
  text-decoration-color: rgb(246 235 211 / 0.45);
}

/* Where hands touch bronze it polishes. */
.plate:hover {
  filter: brightness(1.06) saturate(1.08);
}

.plate:hover .plate-address {
  text-decoration-color: var(--bronze-cut);
}

.plate:active {
  translate: 0 1px;
  box-shadow:
    inset 0 1px 0 rgb(255 232 190 / 0.35),
    0 0.1rem 0.15rem rgb(20 16 8 / 0.3),
    0 0.5rem 1rem -0.5rem rgb(20 16 8 / 0.4);
}

.plate:focus-visible {
  outline-color: var(--ink);
  outline-offset: 5px;
}

/* ---- the next course: projects in preparation ------------------------------ */

.projects {
  margin: 0;
}

/* A string course: the slim band that runs across a façade between storeys. */
.course--string {
  background: var(--stone-dark) var(--limestone);
  background-position: 300px 12px;
}

.string-title {
  margin: 0;
  padding-block: calc(var(--unit) * 1.5);
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.375rem;
  letter-spacing: 0.04em;
  color: var(--cut);
  filter: url(#cut-md);
}

.course--projects {
  display: grid;
  /* Stones of unequal length, their joints staggered against the motto
     course's; the uncut stone is the short one. */
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.1fr) minmax(0, 0.65fr);
  padding: 0;
  list-style: none;
}

.block--project {
  min-height: calc(var(--unit) * 18);
  padding: calc(var(--unit) * 4) calc(var(--unit) * 3) calc(var(--unit) * 5);
}

.block--project:first-child {
  padding-left: max(var(--gutter), (100vw - var(--measure)) / 2);
}

.block--project:last-child {
  padding-right: max(var(--gutter), (100vw - var(--measure)) / 2);
}

.project-name {
  margin: 0 0 calc(var(--unit) * 1.5);
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.875rem, 1.3rem + 1.6vw, 2.75rem);
  line-height: 1.1;
  letter-spacing: 0.01em;
  color: var(--cut-display);
  filter: url(#cut-md);
}

.project-line {
  margin: 0;
  max-width: 34ch;
  color: var(--ink);
  text-shadow: 0 1px 0 rgb(255 255 255 / 0.4);
}

.project-line--quiet {
  color: var(--ink-quiet);
}

/* The third stone is set but not yet cut: only the carver's setting-out
   lines, ruled where the letters will go. */
.setting-out {
  display: block;
  height: clamp(1.875rem, 1.3rem + 1.6vw, 2.75rem);
  margin: calc(var(--unit) * 0.5) 0 calc(var(--unit) * 2);
  max-width: 13rem;
  background:
    linear-gradient(rgb(60 60 54 / 0.3), rgb(60 60 54 / 0.3)) 0 0 / 100% 1px no-repeat,
    linear-gradient(rgb(60 60 54 / 0.3), rgb(60 60 54 / 0.3)) 0 100% / 100% 1px no-repeat;
}

/* ---- the plinth: granite, with the legal facts cut into it ---------------- */

.plinth {
  border-top: 3px solid var(--granite-joint);
  background: var(--granite) var(--granite-grain);
  color: var(--granite-cut);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.plinth-inner {
  width: min(100% - 2 * var(--gutter), var(--measure));
  margin-inline: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: calc(var(--unit) * 3) calc(var(--unit) * 4);
  padding-block: calc(var(--unit) * 5) calc(var(--unit) * 6);
}

.plinth p,
.plinth dl,
.plinth address {
  margin: 0;
}

.plinth-block > * + * {
  margin-top: calc(var(--unit) * 0.5);
}

/* Cut granite shows its lighter crystals; the cut's upper wall is in shade. */
.plinth-name,
.plinth address,
.plinth dd,
.plinth a {
  text-shadow: 0 -1px 0 rgb(0 0 0 / 0.55);
}

.plinth-name {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.5rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.plinth address {
  font-style: normal;
}

.plinth-facts div {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.6rem;
}

.plinth dt {
  color: var(--granite-quiet);
}

.plinth dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

.plinth a {
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
  text-decoration-color: rgb(210 211 207 / 0.5);
  transition: text-decoration-color 0.2s var(--ease-out);
}

.plinth a:hover {
  text-decoration-color: var(--granite-cut);
}

.plinth :focus-visible {
  outline-color: var(--granite-cut);
}

.colophon {
  color: var(--granite-quiet);
}

/* ---- narrower walls ------------------------------------------------------- */

@media (max-width: 64rem) {
  .name {
    filter: url(#cut-lg);
  }
}

@media (max-width: 60rem) {
  .course--motto {
    grid-template-columns: minmax(0, 1fr);
  }

  .course--motto > .block--door {
    justify-content: flex-start;
    border-left: 0;
    border-top: 2px solid var(--joint);
    box-shadow: inset 0 1px 0 var(--joint-lit);
    padding-left: var(--gutter);
  }
}

@media (max-width: 52rem) {
  .course--projects,
  .plinth-inner {
    grid-template-columns: minmax(0, 1fr);
  }

  .block--project {
    min-height: 0;
    padding-inline: var(--gutter);
  }

  .block--project:first-child,
  .block--project:last-child {
    padding-inline: var(--gutter);
  }

  .block--project + .block--project {
    border-left: 0;
    border-top: 2px solid var(--joint);
    box-shadow: inset 0 1px 0 var(--joint-lit);
  }
}

/* On a phone the name is cut in two lines, the legal form on the second. */
@media (max-width: 40rem) {
  .name {
    font-size: calc((100vw - 2 * var(--gutter)) / 7.6);
    line-height: 1.08;
  }

  .name-form {
    display: block;
  }

  .course--top::after {
    content: none;
  }

  .course--top .course-inner {
    font-size: 0.75rem;
    letter-spacing: 0.12em;
  }
}

@media (max-width: 22rem) {
  .place {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .facade::after {
    animation: none;
  }

  .plate {
    transition: none;
  }
}
