/* =========================================================
   tajana.ch — Ingegneria edile
   Stile: tavola tecnica in bianco e nero (solo CSS)
   ========================================================= */

:root {
  --paper: #ffffff;
  --ink: #111111;
  --ink-2: #3a3a3a;
  --muted: #7a7a7a;
  --line: #d9d9d9;
  --grid-fine: rgba(0, 0, 0, .035);
  --grid-major: rgba(0, 0, 0, .07);
  --sans: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --gutter: clamp(16px, 4vw, 56px);
  --ease: cubic-bezier(.22, .8, .2, 1);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  color: var(--ink);
  background-color: var(--paper);
  /* carta millimetrata */
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid-fine) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-fine) 1px, transparent 1px);
  background-size: 50px 50px, 50px 50px, 10px 10px, 10px 10px;
  background-position: -1px -1px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  animation: paperIn 1.2s ease both;
}

@keyframes paperIn {
  from { background-color: #f4f4f4; }
  to   { background-color: var(--paper); }
}

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

/* ---------- Cornice del foglio ---------- */

.sheet {
  position: absolute;
  inset: 12px;
  border: 1px solid var(--ink);
  pointer-events: none;
  z-index: 10;
  animation: sheetIn 1.2s var(--ease) both;
}

@keyframes sheetIn {
  from { clip-path: inset(0 100% 100% 0); }
  to   { clip-path: inset(0 0 0 0); }
}

.corner {
  position: absolute;
  width: 14px;
  height: 14px;
}
.corner::before,
.corner::after {
  content: "";
  position: absolute;
  background: var(--ink);
}
.corner::before { width: 14px; height: 1px; top: 50%; }
.corner::after  { width: 1px; height: 14px; left: 50%; }
.tl { top: -7px; left: -7px; }
.tr { top: -7px; right: -7px; }
.bl { bottom: -7px; left: -7px; }
.br { bottom: -7px; right: -7px; }

/* ---------- Barra superiore ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 32px calc(var(--gutter) + 12px) 0;
  animation: fadeDown .8s .3s var(--ease) both;
}

.brand {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--ink);
  text-decoration: none;
}
.brand span { font-weight: 300; color: var(--muted); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.blink {
  width: 8px;
  height: 8px;
  background: var(--ink);
  animation: blink 1.4s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Hero ---------- */

.hero {
  flex: 1;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  align-items: center;
  gap: clamp(32px, 6vw, 96px);
  padding: clamp(40px, 7vh, 88px) calc(var(--gutter) + 12px) 24px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: .78rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 28px;
  animation: fadeUp .8s .5s var(--ease) both;
}

.eyebrow .num { color: var(--ink); font-weight: 500; }

.eyebrow .rule {
  width: 48px;
  height: 1px;
  background: var(--ink);
  transform-origin: left;
  animation: grow .9s .8s var(--ease) both;
}

@keyframes grow {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

.headline {
  font-size: clamp(3rem, 8.4vw, 6.6rem);
  font-weight: 300;
  line-height: .98;
  letter-spacing: -.045em;
  margin-bottom: 32px;
}

.headline .line {
  display: block;
  overflow: hidden;
  padding-bottom: .06em;
}

.headline .line > span {
  display: inline-block;
  transform: translateY(105%);
  animation: rise 1.1s var(--ease) forwards;
}
.headline .line:nth-child(1) > span { animation-delay: .6s; }
.headline .line:nth-child(2) > span { animation-delay: .75s; }
.headline .line:nth-child(3) > span { animation-delay: .9s; }

.headline em {
  font-style: italic;
  font-weight: 300;
  position: relative;
}

/* sottolineatura tracciata a mano libera */
.headline em::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: .08em;
  height: 2px;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left;
  animation: grow 1s 1.9s var(--ease) forwards;
}

@keyframes rise {
  to { transform: translateY(0); }
}

.lead {
  max-width: 34ch;
  font-size: clamp(1rem, 1.6vw, 1.15rem);
  font-weight: 300;
  line-height: 1.65;
  color: var(--ink-2);
  margin-bottom: 44px;
  animation: fadeUp .9s 1.2s var(--ease) both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Avanzamento a righello ---------- */

.progress {
  max-width: 420px;
  animation: fadeUp .9s 1.4s var(--ease) both;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 10px;
}

@property --n {
  syntax: "<integer>";
  initial-value: 0;
  inherits: false;
}

.pct {
  --n: 70;
  color: var(--ink);
  font-weight: 500;
  counter-reset: n var(--n);
  animation: count 2.4s 1.8s cubic-bezier(.65, 0, .35, 1) both;
}
.pct::after { content: counter(n) "%"; }

@keyframes count {
  from { --n: 0; }
  to   { --n: 70; }
}

.ruler {
  position: relative;
  height: 14px;
  border: 1px solid var(--ink);
  background-image:
    repeating-linear-gradient(90deg, var(--ink) 0 1px, transparent 1px 10%),
    repeating-linear-gradient(90deg, rgba(0,0,0,.35) 0 1px, transparent 1px 2%);
  background-size: 100% 6px, 100% 3px;
  background-repeat: no-repeat;
  background-position: 0 0, 0 0;
}

.fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background-color: var(--ink);
  background-image: repeating-linear-gradient(-45deg, rgba(255,255,255,.22) 0 2px, transparent 2px 7px);
  animation:
    fillUp 2.4s 1.8s cubic-bezier(.65, 0, .35, 1) forwards,
    hatchMove 1.6s linear infinite;
}

@keyframes fillUp    { to { width: 70%; } }
@keyframes hatchMove { to { background-position: 20px 0; } }

.scale {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: .65rem;
  color: var(--muted);
}

/* ---------- Ritratto ---------- */

.portrait {
  justify-self: center;
  width: 100%;
  max-width: 400px;
  animation: fadeUp 1.1s .9s var(--ease) both;
}

.frame {
  position: relative;
  aspect-ratio: 4 / 5;
  padding: 14px;
  border: 1px solid var(--ink);
  background: var(--paper);
  box-shadow: 14px 14px 0 -1px var(--paper), 14px 14px 0 0 var(--ink);
  transition: box-shadow .6s var(--ease), transform .6s var(--ease);
}

.frame:hover {
  transform: translate(-4px, -4px);
  box-shadow: 20px 20px 0 -1px var(--paper), 20px 20px 0 0 var(--ink);
}

.frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 25%;
  filter: grayscale(1) contrast(1.08);
  clip-path: inset(0 0 100% 0);
  animation: reveal 1.4s 1.2s cubic-bezier(.77, 0, .18, 1) forwards;
  transition: filter .8s var(--ease), transform 1.2s var(--ease);
}

.frame:hover img {
  filter: grayscale(1) contrast(1.18) brightness(1.03);
}

@keyframes reveal {
  to { clip-path: inset(0 0 0 0); }
}

/* linea di scansione durante la comparsa */
.scan {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 14px;
  height: 1px;
  background: var(--ink);
  opacity: 0;
  animation: scan 1.4s 1.2s cubic-bezier(.77, 0, .18, 1) forwards;
}

@keyframes scan {
  0%   { top: 14px; opacity: 1; }
  95%  { opacity: 1; }
  100% { top: calc(100% - 14px); opacity: 0; }
}

/* segni di taglio agli angoli */
.crop {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--ink);
  border-style: solid;
  border-width: 0;
}
.c1 { top: -8px;    left: -8px;   border-top-width: 1px;    border-left-width: 1px; }
.c2 { top: -8px;    right: -8px;  border-top-width: 1px;    border-right-width: 1px; }
.c3 { bottom: -8px; left: -8px;   border-bottom-width: 1px; border-left-width: 1px; }
.c4 { bottom: -8px; right: -8px;  border-bottom-width: 1px; border-right-width: 1px; }

figcaption {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 26px;
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-2);
}
figcaption .dash {
  flex: 1;
  height: 0;
  border-top: 1px dashed var(--muted);
}

/* ---------- Disegno di prospetto ---------- */

.drawing {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px calc(var(--gutter) + 12px) 0;
}

.elevation {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  fill: none;
  stroke: var(--ink);
  stroke-linecap: square;
}

.ln {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 1.6s var(--d, 0s) var(--ease) forwards;
}

.ln-main   { stroke-width: 1.6; }
.ln-thin   { stroke-width: .6; stroke: var(--ink-2); animation-duration: 1s; }
.ln-ground { stroke-width: 2; animation-duration: 2.2s; }
.ln-crane  { stroke-width: .8; animation-duration: 2.6s; }

@keyframes draw {
  to { stroke-dashoffset: 0; }
}

.hatch {
  stroke-width: .6;
  stroke: var(--muted);
  opacity: 0;
  animation: appear 1s 1.6s ease forwards;
}

.wip {
  stroke-width: .7;
  stroke-dasharray: 3 3;
  opacity: 0;
  animation: appear 1s var(--d) ease forwards, wipPulse 3s calc(var(--d) + 1s) ease-in-out infinite;
}

@keyframes wipPulse {
  50% { opacity: .35; }
}

.ballast {
  fill: var(--ink);
  stroke: none;
  opacity: 0;
  animation: appear .6s var(--d) ease forwards;
}

.hook {
  stroke-width: .8;
  opacity: 0;
  animation: appear .8s 3s ease forwards, sway 5s 3s ease-in-out infinite;
}

@keyframes sway {
  0%, 100% { transform: rotate(2deg); }
  50%      { transform: rotate(-2deg); }
}

.dims {
  stroke-width: .6;
  stroke: var(--ink-2);
  opacity: 0;
  animation: appear 1s var(--d) ease forwards;
}

.dims text {
  font-family: var(--mono);
  font-size: 9px;
  fill: var(--ink-2);
  stroke: none;
  letter-spacing: .04em;
}

@keyframes appear {
  to { opacity: 1; }
}

/* ---------- Cartiglio (footer) ---------- */

.titleblock {
  width: calc(100% - 2 * (var(--gutter) + 12px));
  max-width: calc(1240px - 2 * (var(--gutter) + 12px));
  margin: 40px auto 36px;
  display: grid;
  grid-template-columns: 2fr repeat(4, 1fr);
  border: 1px solid var(--ink);
  background: var(--paper);
  animation: fadeUp .9s 2.2s var(--ease) both;
}

.cell {
  padding: 12px 16px;
  border-left: 1px solid var(--ink);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.cell:first-child { border-left: 0; }

.cell small {
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

.cell strong {
  font-size: .95rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell.wide strong {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -.01em;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 56px;
  }
  .portrait { max-width: 340px; justify-self: start; }
}

@media (max-width: 640px) {
  .sheet { inset: 8px; }
  .topbar { padding-top: 26px; }
  .status { font-size: .62rem; letter-spacing: .1em; }
  .portrait { max-width: 300px; padding-right: 14px; }
  .titleblock { grid-template-columns: 1fr 1fr; margin-top: 28px; }
  .cell { border-left: 0; border-top: 1px solid var(--ink); }
  .cell:nth-child(even) { border-left: 1px solid var(--ink); }
  .cell.wide { grid-column: 1 / -1; border-top: 0; }
  .cell.wide ~ .cell:nth-child(even) { border-left: 0; }
  .cell.wide ~ .cell:nth-child(odd)  { border-left: 1px solid var(--ink); }
  .dims text { font-size: 14px; }
}

/* ---------- Stampa ---------- */

@media print {
  * { animation: none !important; }
  .ln { stroke-dashoffset: 0; }
  .wip, .hatch, .dims, .hook, .ballast { opacity: 1; }
  .headline .line > span { transform: none; }
  .frame img { clip-path: none; }
  .fill { width: 70%; }
}

/* ---------- Accessibilità: meno movimento ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
