/* The features section of Orrin, a made-up money app: a bento grid of five white tiles on a warm light ground, each
   with a small interface drawing in SVG that wakes up under the pointer. script.js moves the tile body (lift, press)
   and the parts of the drawings; the CSS gives the materials, the light that follows the pointer and the layout. */
:root {
  --ground: #f3f1ec;        /* the page, a warm light grey */
  --ground-deep: #e9e6df;   /* the page in the corners */
  --tile: #ffffff;          /* the tiles */
  --ink: #15171b;           /* the words */
  --muted: #8a8d93;         /* the small words */
  --soft: #e8e9ec;          /* the quiet parts of the drawings */
  --line: rgba(21, 23, 27, 0.07); /* hairlines */
  --accent: #17945f;        /* the one colour: an emerald for money that grows */
  --accent-soft: #dff1e8;   /* the accent, very pale */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--ground);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: relative;
  height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(60% 50% at 20% 0%, rgba(255, 255, 255, 0.9), transparent 70%),
    radial-gradient(70% 60% at 100% 100%, var(--ground-deep), transparent 70%),
    var(--ground);
  overflow: hidden;
}

.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  mix-blend-mode: multiply;
  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='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0.08 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.wrap {
  position: relative;
  width: min(1020px, 94vw);
  height: min(660px, 92vh);
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2.6vh, 26px);
}

/* the head: the mark and one line */
.head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 640;
  font-size: 15px;
  letter-spacing: -0.01em;
  flex: none;
}

.brand__mark {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  transform: translateY(4px);
}

.title {
  margin: 0;
  font-size: clamp(15px, 1.2vw + 1vh, 26px);
  font-weight: 560;
  font-stretch: 92%;
  letter-spacing: -0.025em;
  line-height: 1.1;
  text-align: right;
  text-wrap: balance;
}

.title span {
  color: var(--accent);
  font-stretch: 112%;
  font-weight: 480;
}

/* the grid */
.grid {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: clamp(8px, 1.3vw, 16px);
  grid-template-columns: 1.15fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  grid-template-areas:
    "grow grow round"
    "ask freeze budget";
}

.tile--grow { grid-area: grow; }
.tile--round { grid-area: round; }
.tile--ask { grid-area: ask; }
.tile--freeze { grid-area: freeze; }
.tile--budget { grid-area: budget; }

.tile {
  --mx: 50%;
  --my: 50%;
  --lit: 0;
  position: relative;
  min-width: 0;
  min-height: 0;
  outline: none;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}

.tile__body {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: clamp(14px, 1.6vw, 22px);
  background: var(--tile);
  box-shadow:
    0 0 0 1px var(--line),
    0 1px 1px rgba(21, 23, 27, 0.03),
    0 6px 14px -6px rgba(21, 23, 27, 0.08),
    0 22px 40px -24px rgba(21, 23, 27, 0.14);
  overflow: hidden;
  container-type: size;
  transition: box-shadow 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.tile.is-on .tile__body {
  box-shadow:
    0 0 0 1px rgba(21, 23, 27, 0.09),
    0 1px 1px rgba(21, 23, 27, 0.04),
    0 10px 20px -8px rgba(21, 23, 27, 0.12),
    0 34px 60px -28px rgba(23, 148, 95, 0.26);
}

/* the soft light under the pointer and the bright rim it lights */
.tile__body::before,
.tile__body::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: var(--lit);
  transition: opacity 0.5s ease;
}

.tile__body::before {
  background: radial-gradient(240px circle at var(--mx) var(--my), rgba(23, 148, 95, 0.07), transparent 70%);
}

.tile__body::after {
  padding: 1px;
  background: radial-gradient(180px circle at var(--mx) var(--my), rgba(23, 148, 95, 0.55), rgba(23, 148, 95, 0) 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

.tile__art {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: clamp(8px, 2cqh, 18px) clamp(10px, 4cqw, 22px) 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.art {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.art--round,
.art--ask,
.art--freeze,
.art--budget {
  max-width: 270px;
}

.skel__box { fill: none; stroke: rgba(21, 23, 27, 0.08); stroke-dasharray: 3 3; }
.skel__bar { fill: var(--soft); }
.skel__bar--soft { fill: #f0f1f3; }

.tile__text {
  padding: 0 clamp(12px, 5cqw, 22px) clamp(10px, 7cqh, 20px);
}

.tile__text h2 {
  margin: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: clamp(12px, 5.6cqw, 16px);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
  white-space: nowrap;
}

.tile--grow .tile__text h2 {
  font-size: clamp(12px, 3cqw, 17px);
}

.tile__text p {
  margin: 3px 0 0;
  font-size: clamp(11px, 4.4cqw, 13px);
  color: var(--muted);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile--grow .tile__text p {
  font-size: clamp(11px, 2.4cqw, 13.5px);
}

@container (max-height: 170px) {
  .tile__text p { display: none; }
}

/* savings */
.kpi {
  position: absolute;
  top: clamp(10px, 7cqh, 22px);
  left: clamp(12px, 3.5cqw, 22px);
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 10px;
  z-index: 1;
}

.kpi__label {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.kpi__value {
  font-size: clamp(18px, 6cqw, 30px);
  font-weight: 620;
  font-stretch: 94%;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.kpi__chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px 3px 5px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.kpi__chip svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tile--grow .tile__art {
  padding-top: clamp(40px, 30cqh, 84px);
  padding-bottom: 18px;
}

.months {
  position: absolute;
  left: clamp(10px, 4cqw, 22px);
  right: clamp(10px, 4cqw, 22px);
  bottom: 0;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  opacity: 0.8;
}

.rules path {
  fill: none;
  stroke: var(--soft);
  stroke-width: 1;
  stroke-dasharray: 2 4;
}

.ghost {
  fill: none;
  stroke: #d5d7db;
  stroke-width: 1.4;
  stroke-dasharray: 3 4;
}

.line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linecap: round;
}

.drop {
  stroke: var(--accent);
  stroke-width: 1;
  stroke-dasharray: 2 3;
  opacity: 0.35;
}

.dot {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 2;
}

/* round-ups */
.track { fill: var(--soft); }
.track__on { fill: var(--accent); opacity: 0; }
.knob { fill: #fff; }
.knob__shadow { fill: rgba(21, 23, 27, 0.16); filter: blur(1.5px); }
.row__ic { fill: var(--soft); }
.row__bar { fill: #dcdee2; }
.row__bar--soft { fill: var(--soft); }
.row__amt {
  font-size: 10.5px;
  font-weight: 600;
  fill: var(--accent);
  font-variant-numeric: tabular-nums;
}

.sum {
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-size: 0.92em;
}

/* ask */
.field {
  fill: #f7f7f8;
  stroke: rgba(21, 23, 27, 0.08);
  stroke-width: 1;
}

.spark { fill: var(--accent); }
.ph,
.typed {
  font-size: 11px;
  font-weight: 500;
}
.ph { fill: #a9acb1; }
.typed { fill: var(--ink); }
.caret { fill: var(--accent); }
.bubble {
  fill: #fff;
  stroke: rgba(21, 23, 27, 0.08);
  stroke-width: 1;
  filter: drop-shadow(0 4px 6px rgba(21, 23, 27, 0.06));
}
.ans__big {
  font-size: 17px;
  font-weight: 640;
  letter-spacing: -0.03em;
  fill: var(--ink);
}
.ans__small {
  font-size: 9.5px;
  fill: var(--muted);
}
.mini rect { fill: var(--soft); }
.mini .mini__on { fill: var(--accent); }

/* freeze */
.card__shadow { fill: rgba(21, 23, 27, 0.18); filter: blur(4px); }
.card__edge { fill: none; stroke: rgba(255, 255, 255, 0.12); }
.chip { fill: #c9b98a; }
.chip__lines { fill: none; stroke: rgba(0, 0, 0, 0.25); stroke-width: 0.8; }
.card__num {
  font-size: 10px;
  fill: rgba(255, 255, 255, 0.82);
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
}
.card__name {
  font-size: 10px;
  font-weight: 640;
  fill: rgba(255, 255, 255, 0.9);
  letter-spacing: -0.01em;
}
.frost { fill: #eaf2f7; opacity: 0; }
.lock__bg { fill: #fff; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25)); }
.lock__shackle { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; }
.lock__body { fill: var(--ink); }

.state {
  position: relative;
  display: inline-grid;
  height: 1.3em;
  overflow: hidden;
  font-size: 0.72em;
  font-weight: 600;
  color: var(--muted);
}

.state > span {
  grid-area: 1 / 1;
  line-height: 1.3em;
  text-align: right;
}

.state > span:last-child { color: var(--accent); transform: translateY(110%); }

/* budget */
.ring__track,
.seg {
  fill: none;
  stroke-width: 9;
}
.ring__track { stroke: #f0f1f3; }
.seg { stroke-linecap: round; }
.seg--a { stroke: var(--accent); }
.seg--b { stroke: #7fc8a6; }
.seg--c { stroke: #c9e8d8; }
.ring__num {
  font-size: 17px;
  font-weight: 640;
  letter-spacing: -0.03em;
  fill: var(--ink);
  font-variant-numeric: tabular-nums;
}
.ring__cap {
  font-size: 8.5px;
  fill: var(--muted);
}
.legend text {
  font-size: 9.5px;
  fill: var(--ink);
  font-weight: 500;
}
.lg--a { fill: var(--accent); }
.lg--b { fill: #7fc8a6; }
.lg--c { fill: #c9e8d8; }

/* the phone and the narrow screens: two columns, the savings tile on top */
@media (max-width: 620px) {
  .head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .title { text-align: left; font-size: clamp(14px, 4.2vw, 19px); }
  .grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1.25fr 1fr 1fr;
    grid-template-areas:
      "grow grow"
      "round ask"
      "freeze budget";
  }
}

@media (max-height: 470px) {
  .head { display: none; }
}

@media (hover: hover) {
  .tile { cursor: pointer; }
}
