/* ==========================================================================
   Tilecraft Digital — the Studio
   --------------------------------------------------------------------------
   The workspace is deliberately quiet. The storefront is loud on purpose;
   this is where people look at patterns, so the interface stays neutral and
   the two inks appear only as accents: a focus ring, an active marker, a
   confirmation. Everything else is paper and ink.

   Loaded after css/style.css, which carries the fonts, the color tokens,
   and the light and dark themes.
   ========================================================================== */

:root {
  --studio-bar: 3.5rem;
  --studio-sidebar: 17rem;
}

body.studio-body {
  min-height: 100svh;
  overflow: hidden;
}

/* The workspace is calm, so the page grain is dialled back here. */
body.studio-body::before {
  opacity: calc(var(--grain-opacity) * 0.35);
}

.studio {
  display: flex;
  flex-direction: column;
  height: 100svh;
}

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */

.studio__bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--studio-bar);
  padding-inline: clamp(0.75rem, 2vw, 1.25rem);
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
  position: relative;
  z-index: 20;
}

.studio__home {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.studio__home svg {
  width: 1.5rem;
  height: 1.5rem;
  flex: 0 0 auto;
}

.studio__label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 700;
  color: var(--ink-muted);
  padding-left: 0.75rem;
  margin-left: 0.25rem;
  border-left: 2px solid var(--paper-edge);
}

.studio__bar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 2px solid var(--ink);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: var(--step--1);
  font-weight: 700;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  min-height: 2.25rem;
}

.icon-button svg {
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
}

@media (hover: hover) {
  .icon-button:hover {
    background: var(--ink);
    color: var(--paper);
  }
}

.icon-button--square {
  padding: 0.4rem;
  width: 2.25rem;
  justify-content: center;
}

@media (max-width: 40rem) {
  .icon-button__text {
    display: none;
  }
  .icon-button {
    padding: 0.4rem;
    width: 2.25rem;
    justify-content: center;
  }
}

/* --------------------------------------------------------------------------
   Body: sidebar plus workspace
   -------------------------------------------------------------------------- */

.studio__body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: var(--studio-sidebar) minmax(0, 1fr);
  min-height: 0;
}

.studio__sidebar {
  border-right: 2px solid var(--ink);
  background: var(--paper-sunk);
  overflow-y: auto;
  padding: 1rem 0.75rem 2rem;
  min-height: 0;
}

.studio__group + .studio__group {
  margin-top: 1.5rem;
}

.studio__group h2 {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-muted);
  padding: 0 0.5rem 0.5rem;
  margin: 0;
}

.studio__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.studio__list li {
  margin: 0;
}

.product-button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: var(--step--1);
  font-weight: 600;
  padding: 0.55rem 0.6rem;
  border: 2px solid transparent;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.3;
}

.product-button__dot {
  width: 0.55rem;
  height: 0.55rem;
  flex: 0 0 auto;
  background: var(--teal);
  mix-blend-mode: var(--blend);
}

.product-button__name {
  flex: 1 1 auto;
  min-width: 0;
}

.product-button__lock {
  flex: 0 0 auto;
  width: 0.95rem;
  height: 0.95rem;
  color: var(--ink-faint);
}

@media (hover: hover) {
  .product-button:hover {
    background: var(--paper-raised);
    border-color: var(--paper-edge);
  }
}

.product-button[aria-current='true'] {
  background: var(--paper-raised);
  border-color: var(--ink);
}

.product-button--locked {
  color: var(--ink-muted);
  font-weight: 500;
}

.product-button--locked .product-button__dot {
  background: var(--paper-edge);
  mix-blend-mode: normal;
}

.sidebar-note {
  margin: 1.5rem 0.5rem 0;
  padding-top: 1rem;
  border-top: 1px solid var(--paper-edge);
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.sidebar-note a {
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Workspace
   -------------------------------------------------------------------------- */

.studio__workspace {
  overflow-y: auto;
  min-height: 0;
  padding: clamp(1.25rem, 3vw, 2.5rem);
  background: var(--paper);
}

.studio__workspace:focus {
  outline: none;
}

.workspace-inner {
  max-width: 62rem;
  margin-inline: auto;
}

.module-host {
  min-height: 60svh;
}

/* --------------------------------------------------------------------------
   Welcome and activation
   -------------------------------------------------------------------------- */

.welcome {
  max-width: 46rem;
}

.welcome__title {
  font-size: var(--step-3);
}

.welcome p {
  margin-top: 1rem;
}

.activate-panel {
  margin-top: 2rem;
  border: 2px solid var(--ink);
  background: var(--paper-raised);
  padding: clamp(1.1rem, 3vw, 1.75rem);
}

.activate-panel h3 {
  font-size: var(--step-1);
}

.activate-panel p {
  margin-top: 0.7rem;
  font-size: var(--step--1);
  color: var(--ink-muted);
}

.activate-form {
  margin-top: 1.1rem;
}

.activate-form input {
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.browse-links {
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* --------------------------------------------------------------------------
   Module notices
   -------------------------------------------------------------------------- */

.module-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--ink);
}

.module-head h1 {
  font-size: var(--step-2);
}

.module-head__meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
}

.notice {
  border: 2px solid var(--paper-edge);
  background: var(--paper-raised);
  padding: clamp(1.1rem, 3vw, 1.75rem);
  max-width: 44rem;
}

.notice h2 {
  font-size: var(--step-1);
}

.notice p {
  margin-top: 0.8rem;
  font-size: var(--step--1);
}

.notice--locked {
  border-color: var(--ink);
}

/* --------------------------------------------------------------------------
   Settings dialog
   -------------------------------------------------------------------------- */

dialog.sheet-dialog {
  width: min(100% - 2rem, 42rem);
  max-height: min(90svh, 50rem);
  padding: 0;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}

dialog.sheet-dialog::backdrop {
  background: rgb(10 8 20 / 0.55);
}

.sheet-dialog__inner {
  max-height: inherit;
  display: flex;
  flex-direction: column;
  max-height: min(90svh, 50rem);
}

.sheet-dialog__head {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 2px solid var(--ink);
  background: var(--paper-sunk);
}

.sheet-dialog__head h2 {
  font-size: var(--step-1);
  margin: 0;
}

.sheet-dialog__close {
  margin-left: auto;
}

.sheet-dialog__body {
  overflow-y: auto;
  padding: 1.25rem;
}

.settings-group + .settings-group {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--paper-edge);
}

.settings-group > h3 {
  font-size: var(--step-1);
}

.settings-group > p {
  margin-top: 0.5rem;
  font-size: var(--step--1);
  color: var(--ink-muted);
}

.setting-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.setting-row__label {
  font-weight: 600;
  font-size: var(--step--1);
  flex: 1 1 11rem;
}

.segmented {
  display: inline-flex;
  border: 2px solid var(--ink);
}

.segmented button {
  font: inherit;
  font-size: var(--step--1);
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.segmented button + button {
  border-left: 2px solid var(--ink);
}

.segmented button[aria-pressed='true'] {
  background: var(--ink);
  color: var(--paper);
}

/* --------------------------------------------------------------------------
   License list
   -------------------------------------------------------------------------- */

.license-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.license-list li {
  margin: 0;
}

.license-card {
  border: 2px solid var(--paper-edge);
  background: var(--paper-raised);
  padding: 0.9rem 1rem;
}

.license-card__name {
  font-weight: 700;
}

.license-card__code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  margin-top: 0.3rem;
  overflow-wrap: anywhere;
}

.license-card__meta {
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.license-card__actions {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.license-card__actions button {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.35rem 0.65rem;
  border: 2px solid var(--ink);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

@media (hover: hover) {
  .license-card__actions button:hover {
    background: var(--ink);
    color: var(--paper);
  }
}

.license-card__actions button.is-danger {
  border-color: var(--pink-text);
  color: var(--pink-text);
}

@media (hover: hover) {
  .license-card__actions button.is-danger:hover {
    background: var(--pink-text);
    color: var(--paper-raised);
  }
}

.empty-note {
  margin-top: 1rem;
  font-size: var(--step--1);
  color: var(--ink-muted);
}

/* --------------------------------------------------------------------------
   Walkthrough
   -------------------------------------------------------------------------- */

dialog.walkthrough {
  width: min(100% - 2rem, 32rem);
  padding: 0;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
}

dialog.walkthrough::backdrop {
  background: rgb(10 8 20 / 0.55);
}

.walkthrough__inner {
  padding: 1.5rem;
}

.walkthrough__step {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-muted);
  font-weight: 700;
}

.walkthrough h2 {
  font-size: var(--step-2);
  margin-top: 0.5rem;
}

.walkthrough p {
  margin-top: 0.8rem;
}

.walkthrough__dots {
  display: flex;
  gap: 0.35rem;
  margin-top: 1.5rem;
}

.walkthrough__dots span {
  width: 0.5rem;
  height: 0.5rem;
  background: var(--paper-edge);
}

.walkthrough__dots span[data-active='true'] {
  background: var(--pink);
}

.walkthrough__actions {
  margin-top: 1.25rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.walkthrough__actions .button--ghost {
  margin-left: auto;
}

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 60;
  display: grid;
  gap: 0.5rem;
  width: min(100% - 2rem, 28rem);
  pointer-events: none;
}

.toast {
  border: 2px solid var(--ink);
  background: var(--paper-raised);
  color: var(--ink);
  padding: 0.7rem 0.9rem;
  font-size: var(--step--1);
  font-weight: 600;
  box-shadow: 4px 4px 0 var(--ink);
}

.toast[data-tone='error'] {
  border-color: var(--pink-text);
  box-shadow: 4px 4px 0 var(--pink-text);
}

/* --------------------------------------------------------------------------
   Narrow screens
   -------------------------------------------------------------------------- */

@media (max-width: 52rem) {
  body.studio-body {
    overflow: auto;
  }

  .studio {
    height: auto;
    min-height: 100svh;
  }

  .studio__body {
    grid-template-columns: minmax(0, 1fr);
  }

  .studio__sidebar {
    border-right: 0;
    border-bottom: 2px solid var(--ink);
    overflow: visible;
    padding-bottom: 1.25rem;
  }

  .studio__workspace {
    overflow: visible;
  }
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .toast,
  dialog.sheet-dialog,
  dialog.walkthrough {
    animation: none !important;
    transition: none !important;
  }
}
