// Shared entry presentation extracted from webpos/beta CustomerScreens.
@import './icons.less';

.self-service-entry {
  // Slot icons and feedback share the entry scale, regardless of the host reset.
  .sse-action-icon > * {
    width: 1em;
    height: 1em;
  }
  .sse-canvas .sse-scan-hint {
    border: 0;
    text-align: left;
    font-size: 26px;
    &:disabled {
      opacity: 0.55;
      cursor: default;
    }
  }
  .sse-canvas button.sse-scan-hint {
    width: 100%;
  }
  .sse-unavailable {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    text-align: center;
    > .sse-icon {
      font-size: 80px;
      color: var(--sse-primary);
    }
    h1 {
      max-width: min(100%, 14ch);
      font-size: 56px;
      line-height: 1.05;
    }
    p {
      max-width: 30ch;
      font-size: 24px;
      line-height: 1.4;
    }
  }
  .sse-unavailable-compact {
    flex-direction: row;
    padding: 28px;
    border: 1px solid rgba(36, 28, 63, 0.1);
    border-radius: 24px;
    background: white;
    text-align: left;
    > .sse-icon {
      font-size: 40px;
    }
    p {
      max-width: none;
      font-size: 20px;
    }
  }
  // Measurements, colors, shapes and hierarchy taken from the prototype's rendered DOM.
  & {
    container: self-service-entry / inline-size;
    position: relative;
    flex: 1;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--sse-page-bg);
  }

  .sse-canvas {
    --sse-gutter: 32px;
    --sse-ink: #241c3f;
    --sse-primary: var(--sse-theme-primary);
    --sse-soft: var(--sse-soft-bg);
    --sse-accent: #c8f04a;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    color: var(--sse-ink);
    background: var(--sse-page-bg);
    font-family: inherit;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    *,
    *::before,
    *::after {
      box-sizing: border-box;
    }
    p,
    h1,
    h2 {
      margin: 0;
      color: inherit;
    }
    h1,
    h2,
    .sse-touch-label,
    .sse-action-title {
      font-family: inherit;
      font-weight: 700;
      letter-spacing: -0.02em;
    }
    button {
      font: inherit;
      cursor: pointer;
    }
    button:focus-visible {
      outline: 3px solid var(--sse-primary);
      outline-offset: 4px;
    }
  }

  .sse-idle {
    --sse-blob-purple-opacity: 0.1;

    @supports (color: color-mix(in srgb, white, black)) {
      --sse-page-surface: color-mix(
        in srgb,
        white var(--sse-page-white-percent),
        var(--sse-theme-primary)
      );
      --sse-blob-purple-surface: color-mix(
        in srgb,
        var(--sse-page-surface),
        var(--sse-primary) calc(var(--sse-blob-purple-opacity) * 100%)
      );
    }
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overflow-y: auto;
    user-select: none;

    > .vm-customer-technical-support .pisell-brand__content::before {
      background-image: linear-gradient(
        to bottom,
        var(--brand-surface) var(--pisell-brand-top-height),
        transparent
      );
    }
  }
  .sse-shapes {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
  }
  .sse-blob {
    position: absolute;
    animation: sse-drift 7s ease-in-out infinite;
  }
  .sse-blob-purple {
    top: -112px;
    right: -144px;
    width: 440px;
    height: 440px;
    border-radius: 46% 54% 58% 42% / 48% 38% 62% 52%;
    background: var(--sse-primary);
    opacity: var(--sse-blob-purple-opacity);
    animation-duration: 11s;
  }
  .sse-blob-lime {
    top: 46%;
    left: -96px;
    width: 300px;
    height: 300px;
    border-radius: 58% 42% 44% 56% / 52% 60% 40% 48%;
    background: var(--sse-accent);
    opacity: 0.6;
    animation-duration: 9s;
    animation-delay: -3s;
  }
  .sse-blob-ring {
    top: 30%;
    right: 40px;
    width: 180px;
    height: 180px;
    border: 18px solid var(--sse-primary);
    border-radius: 50%;
    opacity: 0.15;
    animation-duration: 8s;
    animation-delay: -5s;
  }
  .sse-blob-soft {
    right: -48px;
    bottom: 96px;
    width: 220px;
    height: 220px;
    border-radius: 52% 48% 40% 60% / 44% 56%;
    background: var(--sse-soft);
    animation-duration: 13s;
    animation-delay: -7s;
  }
  .sse-blob-small {
    bottom: 38%;
    left: 42%;
    width: 72px;
    height: 72px;
    border: 10px solid var(--sse-ink);
    border-radius: 50%;
    opacity: 0.1;
    animation-delay: -2s;
  }
  .sse-idle-layout {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-rows: auto minmax(200px, 1fr) auto;
    row-gap: 32px;
    flex: 1 0 auto;
    min-height: min-content;
    padding: 28px 40px 40px;
  }
  .sse-idle-header,
  .sse-idle-actions,
  .sse-idle-footer {
    min-width: 0;
  }
  .sse-idle-actions {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .sse-idle-footer {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    .sse-scan-hint-pill {
      margin-top: 0;
    }
  }
  .sse-brand {
    display: flex;
    flex-shrink: 0;
    min-width: 0;
    max-width: 100%;
    align-items: center;
    gap: 16px;
    > div {
      min-width: 0;
    }
    .sse-logo {
      display: block;
      flex: 0 0 72px;
      width: 72px;
      height: 72px;
      object-fit: contain;
    }
    .sse-monogram {
      display: flex;
      flex: 0 0 72px;
      align-items: center;
      justify-content: center;
      width: 72px;
      height: 72px;
      border-radius: 20px;
      background: var(--sse-ink);
      color: var(--sse-accent);
      font-size: 32px;
      font-weight: 700;
      line-height: 1.25;
    }
    .sse-brand-name {
      font-size: 32px;
      font-weight: 600;
      line-height: 1.25;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .sse-brand-subtitle {
      color: rgba(36, 28, 63, 0.7);
      font-size: 22px;
      line-height: 1.4;
      min-height: 24px;
    }
  }
  .sse-idle-copy {
    flex-shrink: 0;
    margin-top: 56px;
    h1 {
      font-size: 64px;
      line-height: 1;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 3;
      overflow: hidden;
    }
    p {
      max-width: 30ch;
      margin-top: 24px;
      color: rgba(36, 28, 63, 0.7);
      font-size: 30px;
      line-height: 1.4;
    }
  }
  .sse-start {
    display: flex;
    flex-shrink: 0;
    flex-direction: column;
    align-items: center;
  }
  .sse-touch {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 112px;
    height: 112px;
  }
  .sse-pulse {
    position: absolute;
    inset: 0;
    border: 4px solid var(--sse-primary);
    border-radius: 50%;
    animation: sse-pulse 1.8s ease-out infinite;
    &:nth-child(2) {
      animation-delay: 0.9s;
    }
  }
  .sse-hand {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--sse-primary);
    color: var(--sse-theme-primary-foreground);
    font-size: 40px;
  }
  .sse-start .sse-touch-label {
    margin-top: 16px;
    font-size: 30px;
    line-height: 45px;
  }
  .sse-scan-hint {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
    padding: 16px 20px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.6);
    color: rgba(36, 28, 63, 0.75);
    font-size: 26px;
    line-height: 1.4;
    > span:not(.sse-icon) {
      flex: 1;
    }
    .sse-icon:first-child {
      font-size: 36px;
      color: var(--sse-primary);
    }
    .sse-icon:last-child {
      font-size: 32px;
      color: rgba(36, 28, 63, 0.65);
    }
  }
  .sse-scan-hint-pill {
    margin-top: 20px;
    padding: 12px 20px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.8);
    line-height: 1.4;
  }
  .sse-canvas .sse-idle-hitarea {
    position: absolute;
    z-index: 2;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    padding: 0;
    background: transparent;
    &:focus-visible {
      outline-offset: -6px;
    }
  }
  .sse-home {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
  }
  .sse-home-header {
    display: flex;
    align-items: center;
    height: 80px;
    flex: 0 0 80px;
    padding: 0 var(--sse-gutter);
  }
  .sse-home-toolbar {
    position: relative;
    z-index: 3;
    justify-content: space-between;
    gap: 24px;
    > .sse-brand {
      flex: 1 1 auto;
    }
  }
  .sse-language {
    position: relative;
    display: grid;
    flex: 0 0 auto;
    grid-template-columns: 28px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 10px;
    width: 220px;
    min-height: 56px;
    padding: 0 16px;
    border: 1px solid rgba(36, 28, 63, 0.14);
    border-radius: 999px;
    background: #fff;
    color: var(--sse-ink);
    > svg {
      width: 100%;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
      pointer-events: none;
    }
    > svg:first-child {
      color: var(--sse-primary);
    }
    select {
      width: 100%;
      min-width: 0;
      min-height: 54px;
      border: 0;
      padding: 0;
      outline: 0;
      appearance: none;
      background: transparent;
      color: inherit;
      font: inherit;
      font-size: 20px;
      font-weight: 600;
      cursor: pointer;
      option {
        background: #fff;
        color: #241c3f;
      }
      &:disabled {
        cursor: default;
      }
    }
    &:focus-within {
      outline: 3px solid var(--sse-primary);
      outline-offset: 4px;
    }
    &[data-disabled='true'] {
      opacity: 0.5;
    }
  }
  .sse-brand-compact {
    gap: 16px;
    .sse-logo {
      flex-basis: 56px;
      width: 56px;
      height: 56px;
    }
    .sse-monogram {
      flex-basis: 56px;
      width: 56px;
      height: 56px;
      border-radius: 16px;
      font-size: 24px;
    }
    .sse-brand-name {
      font-size: 28px;
      color: rgba(36, 28, 63, 0.75);
    }
  }
  .sse-home-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px var(--sse-gutter);
    > h1 {
      font-size: 48px;
      line-height: 1.05;
    }
    .sse-home-description {
      margin-top: 12px;
      max-width: 38ch;
      font-size: 28px;
      line-height: 1.4;
      color: rgba(36, 28, 63, 0.7);
    }
  }
  .sse-actions {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 32px;
  }
  .sse-action {
    display: flex;
    align-items: center;
    gap: 32px;
    min-height: clamp(340px, 42cqw, 520px);
    width: 100%;
    border: 1px solid rgba(36, 28, 63, 0.1);
    border-radius: 40px;
    padding: 44px;
    color: var(--sse-ink);
    background: #fff;
    text-align: left;
    touch-action: manipulation;
    &:hover:not(:disabled) .sse-action-icon {
      background: var(--sse-theme-primary-hover);
    }
    &:active:not(:disabled) {
      transform: scale(0.99);
      .sse-action-icon {
        background: var(--sse-theme-primary-active);
      }
    }
    &:disabled {
      opacity: 0.55;
      cursor: wait;
    }
    > .sse-icon {
      font-size: 44px;
      color: rgba(36, 28, 63, 0.3);
    }
  }
  .sse-action-icon {
    display: flex;
    flex: 0 0 160px;
    align-items: center;
    justify-content: center;
    width: 160px;
    height: 160px;
    border-radius: 44px;
    background: var(--sse-primary);
    color: var(--sse-theme-primary-foreground);
    font-size: 80px;
  }
  .sse-action-accent {
    .sse-action-icon,
    &:hover:not(:disabled) .sse-action-icon,
    &:active:not(:disabled) .sse-action-icon {
      background: var(--sse-accent);
      color: var(--sse-ink);
    }
  }
  .sse-action-copy {
    flex: 1;
    min-width: 0;
  }
  .sse-action-title {
    display: block;
    overflow-wrap: anywhere;
    font-size: clamp(40px, 5.2cqw, 56px);
    line-height: 1.25;
  }
  .sse-action-description {
    display: block;
    overflow-wrap: anywhere;
    margin-top: 8px;
    font-size: 28px;
    line-height: 1.375;
    color: rgba(36, 28, 63, 0.7);
  }
  .sse-load-error {
    margin-top: 16px;
  }
  .sse-home-footer {
    flex-shrink: 0;
    padding: 12px var(--sse-gutter) 20px;
  }
  .sse-canvas .sse-help {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    min-height: 72px;
    border: 2px solid rgba(36, 28, 63, 0.14);
    border-radius: 16px;
    background: #fff;
    color: var(--sse-ink);
    font-size: 22px;
    font-weight: 600;
    .sse-icon {
      font-size: 28px;
    }
  }
  .sse-machine-row {
    display: flex;
    align-items: center;
    margin-top: 16px;
  }
  .sse-canvas .sse-machine {
    padding: 4px 0;
    border: 0;
    background: none;
    font-size: 18px;
    line-height: 1.4;
    color: rgba(36, 28, 63, 0.65);
    cursor: default;
    user-select: none;
  }

  // Give readable copy more space on portrait tablet hosts.
  @container self-service-entry (min-width: 621px) and (max-width: 900px) {
    .sse-canvas {
      .sse-action {
        gap: 24px;
        min-height: 240px;
        padding: 28px;
        > .sse-icon {
          font-size: 32px;
        }
      }
      .sse-action-icon {
        flex-basis: 112px;
        width: 112px;
        height: 112px;
        border-radius: 32px;
        font-size: 56px;
      }
    }
  }

  // Reflow compact hosts instead of scaling the entire page and its controls.
  @container self-service-entry (max-width: 620px) {
    .sse-canvas {
      --sse-gutter: 18px;

      .sse-home-toolbar {
        gap: 12px;
        .sse-brand {
          gap: 10px;
        }
        .sse-brand-name {
          font-size: 22px;
        }
        .sse-logo,
        .sse-monogram {
          flex-basis: 44px;
          width: 44px;
          height: 44px;
        }
      }
      .sse-language {
        grid-template-columns: 22px minmax(0, 1fr) 16px;
        gap: 6px;
        width: 168px;
        min-height: 48px;
        padding-inline: 12px;
        select {
          min-height: 46px;
          font-size: 16px;
        }
      }

      .sse-idle-layout {
        grid-template-rows: auto minmax(160px, 1fr) auto;
        gap: 24px;
        padding: 20px 20px 24px;
      }
      .sse-idle-copy {
        margin-top: 32px;
        h1 {
          font-size: 44px;
        }
        p {
          margin-top: 16px;
          font-size: 26px;
        }
      }
      .sse-home-content > h1 {
        font-size: 36px;
      }
      .sse-home-description {
        font-size: 24px;
      }
      .sse-action {
        gap: 20px;
        min-height: 260px;
        padding: 24px;
        > .sse-icon {
          font-size: 24px;
        }
      }
      .sse-action-icon {
        flex-basis: 88px;
        width: 88px;
        height: 88px;
        border-radius: 26px;
        font-size: 48px;
      }
      .sse-action-title {
        font-size: 36px;
      }
      .sse-action-description {
        font-size: 24px;
      }
      .sse-scan-hint {
        gap: 10px;
        font-size: 22px;
      }
    }
  }

  @container self-service-entry (max-width: 420px) {
    .sse-canvas {
      .sse-action {
        gap: 12px;
        padding: 20px;
      }
      .sse-action-icon {
        flex-basis: 64px;
        width: 64px;
        height: 64px;
        font-size: 36px;
      }
      .sse-action-title {
        font-size: 30px;
      }
      .sse-action-description {
        font-size: 22px;
      }
    }
  }

  @keyframes sse-drift {
    0%,
    100% {
      transform: translate(0) rotate(0);
    }
    50% {
      transform: translate(12px, -18px) rotate(6deg);
    }
  }
  @keyframes sse-pulse {
    0% {
      opacity: 0.8;
      transform: scale(0.9);
    }
    100% {
      opacity: 0;
      transform: scale(1.6);
    }
  }
  .sse-paused .sse-blob,
  .sse-paused .sse-pulse {
    animation-play-state: paused;
  }
  @media (prefers-reduced-motion: reduce) {
    .sse-blob,
    .sse-pulse {
      animation: none;
    }
    .sse-pulse {
      opacity: 0.25;
    }
  }
}
